@arbor-education/ask-arbor-chat-panel 1.0.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.
package/dist/index.js ADDED
@@ -0,0 +1,3216 @@
1
+ import { jsxs as S, jsx as i, Fragment as we } from "react/jsx-runtime";
2
+ import { Icon as vt, Tag as Tr, Tabs as nn, Table as Er } from "@arbor-education/design-system.components";
3
+ import { useRef as x, useMemo as Qn, useEffect as V, useState as M, useContext as Ar, createContext as Sr, forwardRef as Tn, createElement as pn, useImperativeHandle as wr, useLayoutEffect as er, useCallback as Wt } from "react";
4
+ import { createPortal as Nr } from "react-dom";
5
+ function kr(e) {
6
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
+ }
8
+ var tr = { exports: {} };
9
+ /*!
10
+ Copyright (c) 2018 Jed Watson.
11
+ Licensed under the MIT License (MIT), see
12
+ http://jedwatson.github.io/classnames
13
+ */
14
+ (function(e) {
15
+ (function() {
16
+ var n = {}.hasOwnProperty;
17
+ function r() {
18
+ for (var s = "", u = 0; u < arguments.length; u++) {
19
+ var m = arguments[u];
20
+ m && (s = l(s, a(m)));
21
+ }
22
+ return s;
23
+ }
24
+ function a(s) {
25
+ if (typeof s == "string" || typeof s == "number")
26
+ return s;
27
+ if (typeof s != "object")
28
+ return "";
29
+ if (Array.isArray(s))
30
+ return r.apply(null, s);
31
+ if (s.toString !== Object.prototype.toString && !s.toString.toString().includes("[native code]"))
32
+ return s.toString();
33
+ var u = "";
34
+ for (var m in s)
35
+ n.call(s, m) && s[m] && (u = l(u, m));
36
+ return u;
37
+ }
38
+ function l(s, u) {
39
+ return u ? s ? s + " " + u : s + u : s;
40
+ }
41
+ e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
42
+ })();
43
+ })(tr);
44
+ var Rr = tr.exports;
45
+ const _e = /* @__PURE__ */ kr(Rr);
46
+ function Ir(e, n, r, a) {
47
+ var l = this, s = x(null), u = x(0), m = x(0), h = x(null), p = x([]), T = x(), A = x(), _ = x(e), E = x(!0), k = x(), O = x();
48
+ _.current = e;
49
+ var w = typeof window < "u", N = !n && n !== 0 && w;
50
+ if (typeof e != "function") throw new TypeError("Expected a function");
51
+ n = +n || 0;
52
+ var H = !!(r = r || {}).leading, pe = !("trailing" in r) || !!r.trailing, z = !!r.flushOnExit && pe, K = "maxWait" in r, U = "debounceOnServer" in r && !!r.debounceOnServer, q = K ? Math.max(+r.maxWait || 0, n) : null, me = Qn(function() {
53
+ var J = function(D) {
54
+ var W = p.current, he = T.current;
55
+ return p.current = T.current = null, u.current = D, m.current = m.current || D, A.current = _.current.apply(he, W);
56
+ }, G = function(D, W) {
57
+ N && cancelAnimationFrame(h.current), h.current = N ? requestAnimationFrame(D) : setTimeout(D, W);
58
+ }, de = function(D) {
59
+ if (!E.current) return !1;
60
+ var W = D - s.current;
61
+ return !s.current || W >= n || W < 0 || K && D - u.current >= q;
62
+ }, b = function(D) {
63
+ return h.current = null, pe && p.current ? J(D) : (p.current = T.current = null, A.current);
64
+ }, L = function D() {
65
+ var W = Date.now();
66
+ if (H && m.current === u.current && B(), de(W)) return b(W);
67
+ if (E.current) {
68
+ var he = n - (W - s.current), Le = K ? Math.min(he, q - (W - u.current)) : he;
69
+ G(D, Le);
70
+ }
71
+ }, B = function() {
72
+ }, re = function() {
73
+ if (w || U) {
74
+ var D, W = Date.now(), he = de(W);
75
+ if (p.current = [].slice.call(arguments), T.current = l, s.current = W, z && !k.current && (k.current = function() {
76
+ var Le;
77
+ ((Le = globalThis.document) == null ? void 0 : Le.visibilityState) === "hidden" && O.current.flush();
78
+ }, (D = globalThis.document) == null || D.addEventListener == null || D.addEventListener("visibilitychange", k.current)), he) {
79
+ if (!h.current && E.current) return u.current = s.current, G(L, n), H ? J(s.current) : A.current;
80
+ if (K) return G(L, n), J(s.current);
81
+ }
82
+ return h.current || G(L, n), A.current;
83
+ }
84
+ };
85
+ return re.cancel = function() {
86
+ var D = h.current;
87
+ D && (N ? cancelAnimationFrame(h.current) : clearTimeout(h.current)), u.current = 0, p.current = s.current = T.current = h.current = null;
88
+ }, re.isPending = function() {
89
+ return !!h.current;
90
+ }, re.flush = function() {
91
+ return h.current ? b(Date.now()) : A.current;
92
+ }, re;
93
+ }, [H, K, n, q, pe, z, N, w, U, a]);
94
+ return O.current = me, V(function() {
95
+ return E.current = !0, function() {
96
+ var J;
97
+ z && O.current.flush(), k.current && ((J = globalThis.document) == null || J.removeEventListener == null || J.removeEventListener("visibilitychange", k.current), k.current = null), E.current = !1;
98
+ };
99
+ }, [z]), me;
100
+ }
101
+ const Cr = () => /* @__PURE__ */ S(
102
+ "svg",
103
+ {
104
+ width: "32",
105
+ height: "32",
106
+ viewBox: "0 0 14 14",
107
+ fill: "none",
108
+ xmlns: "http://www.w3.org/2000/svg",
109
+ "aria-hidden": "true",
110
+ children: [
111
+ /* @__PURE__ */ i(
112
+ "path",
113
+ {
114
+ d: "M9.76794 5.1605L10.9845 5.50809C11.1003 5.54083 11.1784 5.64662 11.1784 5.765C11.1784 5.88338 11.1003 5.98917 10.9845 6.02191L9.76794 6.3695L9.42036 7.58606C9.38761 7.70192 9.28183 7.78 9.16344 7.78C9.04506 7.78 8.93928 7.70192 8.90653 7.58606L8.55894 6.3695L7.34239 6.02191C7.22653 5.98917 7.14844 5.88338 7.14844 5.765C7.14844 5.64662 7.22653 5.54083 7.34239 5.50809L8.55894 5.1605L8.90653 3.94394C8.93928 3.82808 9.04506 3.75 9.16344 3.75C9.28183 3.75 9.38761 3.82808 9.42036 3.94394L9.76794 5.1605Z",
115
+ fill: "#F7941D"
116
+ }
117
+ ),
118
+ /* @__PURE__ */ i(
119
+ "path",
120
+ {
121
+ d: "M6.67581 3.31451L7.42144 3.52755C7.49245 3.54762 7.54031 3.61246 7.54031 3.68501C7.54031 3.75757 7.49245 3.82241 7.42144 3.84247L6.67581 4.05551L6.46277 4.80114C6.4427 4.87216 6.37786 4.92001 6.30531 4.92001C6.23275 4.92001 6.16791 4.87216 6.14784 4.80114L5.93481 4.05551L5.18918 3.84247C5.11816 3.82241 5.07031 3.75757 5.07031 3.68501C5.07031 3.61246 5.11816 3.54762 5.18918 3.52755L5.93481 3.31451L6.14784 2.56888C6.16791 2.49787 6.23275 2.45001 6.30531 2.45001C6.37786 2.45001 6.4427 2.49787 6.46277 2.56888L6.67581 3.31451Z",
122
+ fill: "#CFDD27"
123
+ }
124
+ ),
125
+ /* @__PURE__ */ i(
126
+ "path",
127
+ {
128
+ d: "M6.49287 7.78652L8.18036 8.26865C8.34107 8.31407 8.44938 8.46081 8.44938 8.62502C8.44938 8.78922 8.34107 8.93596 8.18036 8.98138L6.49287 9.46352L6.01074 11.151C5.96532 11.3117 5.81857 11.42 5.65437 11.42C5.49016 11.42 5.34342 11.3117 5.298 11.151L4.81587 9.46352L3.1284 8.98138C2.96768 8.93596 2.85938 8.78922 2.85938 8.62502C2.85938 8.46081 2.96768 8.31407 3.1284 8.26865L4.81587 7.78652L5.298 6.09904C5.34342 5.93832 5.49016 5.83002 5.65437 5.83002C5.81857 5.83002 5.96532 5.93832 6.01074 6.09904L6.49287 7.78652Z",
129
+ fill: "#7BB93C"
130
+ }
131
+ )
132
+ ]
133
+ }
134
+ ), vr = "Enter", Or = " ", Ln = ({
135
+ category: e,
136
+ isExpanded: n,
137
+ onHeaderClick: r
138
+ }) => {
139
+ const a = `ask-arbor-prompt-library__body-${e.id}`, l = (s) => {
140
+ (s.key === vr || s.key === Or) && (s.preventDefault(), r(e.id));
141
+ };
142
+ return /* @__PURE__ */ i(
143
+ "div",
144
+ {
145
+ className: _e(
146
+ "ask-arbor-prompt-library__category",
147
+ `ask-arbor-prompt-library__category--${e.theme}`,
148
+ {
149
+ "ask-arbor-prompt-library__category--expanded": n
150
+ }
151
+ ),
152
+ children: /* @__PURE__ */ S(
153
+ "div",
154
+ {
155
+ className: "ask-arbor-prompt-library__header",
156
+ onClick: () => r(e.id),
157
+ onKeyDown: l,
158
+ role: "button",
159
+ tabIndex: 0,
160
+ "aria-expanded": n,
161
+ "aria-controls": a,
162
+ "aria-label": `${e.title}, ${n ? "collapse" : "expand"} to ${n ? "hide" : "show"} prompts`,
163
+ children: [
164
+ /* @__PURE__ */ i("div", { className: "ask-arbor-prompt-library__icon-circle", children: /* @__PURE__ */ i(
165
+ vt,
166
+ {
167
+ name: e.icon,
168
+ size: 12,
169
+ screenReaderText: e.title
170
+ }
171
+ ) }),
172
+ /* @__PURE__ */ i("div", { className: "ask-arbor-prompt-library__header-text", children: /* @__PURE__ */ i("h4", { className: "ask-arbor-prompt-library__title", children: e.title }) }),
173
+ /* @__PURE__ */ i(
174
+ vt,
175
+ {
176
+ name: n ? "chevron-up" : "chevron-down",
177
+ size: 16,
178
+ screenReaderText: n ? "Collapse section" : "Expand section",
179
+ className: "ask-arbor-prompt-library__chevron"
180
+ }
181
+ ),
182
+ /* @__PURE__ */ i("p", { className: "ask-arbor-prompt-library__description", children: e.description })
183
+ ]
184
+ }
185
+ )
186
+ }
187
+ );
188
+ }, Lr = ({
189
+ onSelectPrompt: e,
190
+ onPromptHover: n,
191
+ categories: r
192
+ }) => {
193
+ const [a, l] = M(
194
+ null
195
+ ), s = (_) => {
196
+ l(
197
+ (E) => E === _ ? null : _
198
+ );
199
+ }, u = (_, E) => {
200
+ _.stopPropagation(), e(E);
201
+ }, m = a != null ? r.findIndex((_) => _.id === a) : -1, h = m >= 0 ? r[m] : null, p = (_) => /* @__PURE__ */ i(
202
+ "div",
203
+ {
204
+ className: "ask-arbor-prompt-library__grid-item ask-arbor-prompt-library__grid-item--full-width",
205
+ children: /* @__PURE__ */ S("div", { className: "ask-arbor-prompt-library__expanded-block", children: [
206
+ /* @__PURE__ */ i(
207
+ Ln,
208
+ {
209
+ category: _,
210
+ isExpanded: !0,
211
+ onHeaderClick: s
212
+ }
213
+ ),
214
+ /* @__PURE__ */ i(
215
+ "div",
216
+ {
217
+ id: `ask-arbor-prompt-library__body-${_.id}`,
218
+ className: "ask-arbor-prompt-library__drawer",
219
+ role: "region",
220
+ "aria-label": `${_.title} prompts`,
221
+ children: _.promptGroups.map((E) => /* @__PURE__ */ S(
222
+ "div",
223
+ {
224
+ className: "ask-arbor-prompt-library__prompt-group",
225
+ children: [
226
+ /* @__PURE__ */ i(Tr, { color: _.theme, children: E.tag }),
227
+ /* @__PURE__ */ i("div", { className: "ask-arbor-prompt-library__prompts", children: E.prompts.map((k, O) => /* @__PURE__ */ S(
228
+ "button",
229
+ {
230
+ type: "button",
231
+ className: "ask-arbor-prompt-library__prompt-row",
232
+ onClick: (w) => u(w, k),
233
+ onMouseEnter: () => n == null ? void 0 : n(k),
234
+ onMouseLeave: () => n == null ? void 0 : n(null),
235
+ children: [
236
+ /* @__PURE__ */ i("span", { className: "ask-arbor-prompt-library__prompt-text", children: k }),
237
+ /* @__PURE__ */ i(
238
+ vt,
239
+ {
240
+ name: "chevron-right",
241
+ size: 12,
242
+ screenReaderText: "Submit prompt"
243
+ }
244
+ )
245
+ ]
246
+ },
247
+ `${E.tag}-${O}`
248
+ )) })
249
+ ]
250
+ },
251
+ E.tag
252
+ ))
253
+ }
254
+ )
255
+ ] })
256
+ },
257
+ _.id
258
+ ), T = (_) => /* @__PURE__ */ i("div", { className: "ask-arbor-prompt-library__grid-item", children: /* @__PURE__ */ i(
259
+ Ln,
260
+ {
261
+ category: _,
262
+ isExpanded: !1,
263
+ onHeaderClick: s
264
+ }
265
+ ) }, _.id), A = m >= 0 ? [
266
+ ...r.slice(0, m).map(T),
267
+ p(h),
268
+ ...r.slice(m + 1).map(T)
269
+ ] : r.map(T);
270
+ return /* @__PURE__ */ i(
271
+ "div",
272
+ {
273
+ className: "ask-arbor-prompt-library",
274
+ "data-testid": "ask-arbor-prompt-library",
275
+ children: /* @__PURE__ */ i("div", { className: "ask-arbor-prompt-library__grid", children: A })
276
+ }
277
+ );
278
+ };
279
+ /**
280
+ * @license lucide-react v1.21.0 - ISC
281
+ *
282
+ * This source code is licensed under the ISC license.
283
+ * See the LICENSE file in the root directory of this source tree.
284
+ */
285
+ const nr = (...e) => e.filter((n, r, a) => !!n && n.trim() !== "" && a.indexOf(n) === r).join(" ").trim();
286
+ /**
287
+ * @license lucide-react v1.21.0 - ISC
288
+ *
289
+ * This source code is licensed under the ISC license.
290
+ * See the LICENSE file in the root directory of this source tree.
291
+ */
292
+ const Dr = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
293
+ /**
294
+ * @license lucide-react v1.21.0 - ISC
295
+ *
296
+ * This source code is licensed under the ISC license.
297
+ * See the LICENSE file in the root directory of this source tree.
298
+ */
299
+ const Mr = (e) => e.replace(
300
+ /^([A-Z])|[\s-_]+(\w)/g,
301
+ (n, r, a) => a ? a.toUpperCase() : r.toLowerCase()
302
+ );
303
+ /**
304
+ * @license lucide-react v1.21.0 - ISC
305
+ *
306
+ * This source code is licensed under the ISC license.
307
+ * See the LICENSE file in the root directory of this source tree.
308
+ */
309
+ const Dn = (e) => {
310
+ const n = Mr(e);
311
+ return n.charAt(0).toUpperCase() + n.slice(1);
312
+ };
313
+ /**
314
+ * @license lucide-react v1.21.0 - ISC
315
+ *
316
+ * This source code is licensed under the ISC license.
317
+ * See the LICENSE file in the root directory of this source tree.
318
+ */
319
+ var rn = {
320
+ xmlns: "http://www.w3.org/2000/svg",
321
+ width: 24,
322
+ height: 24,
323
+ viewBox: "0 0 24 24",
324
+ fill: "none",
325
+ stroke: "currentColor",
326
+ strokeWidth: 2,
327
+ strokeLinecap: "round",
328
+ strokeLinejoin: "round"
329
+ };
330
+ /**
331
+ * @license lucide-react v1.21.0 - ISC
332
+ *
333
+ * This source code is licensed under the ISC license.
334
+ * See the LICENSE file in the root directory of this source tree.
335
+ */
336
+ const xr = (e) => {
337
+ for (const n in e)
338
+ if (n.startsWith("aria-") || n === "role" || n === "title")
339
+ return !0;
340
+ return !1;
341
+ }, Pr = Sr({}), Ur = () => Ar(Pr), Fr = Tn(
342
+ ({ color: e, size: n, strokeWidth: r, absoluteStrokeWidth: a, className: l = "", children: s, iconNode: u, ...m }, h) => {
343
+ const {
344
+ size: p = 24,
345
+ strokeWidth: T = 2,
346
+ absoluteStrokeWidth: A = !1,
347
+ color: _ = "currentColor",
348
+ className: E = ""
349
+ } = Ur() ?? {}, k = a ?? A ? Number(r ?? T) * 24 / Number(n ?? p) : r ?? T;
350
+ return pn(
351
+ "svg",
352
+ {
353
+ ref: h,
354
+ ...rn,
355
+ width: n ?? p ?? rn.width,
356
+ height: n ?? p ?? rn.height,
357
+ stroke: e ?? _,
358
+ strokeWidth: k,
359
+ className: nr("lucide", E, l),
360
+ ...!s && !xr(m) && { "aria-hidden": "true" },
361
+ ...m
362
+ },
363
+ [
364
+ ...u.map(([O, w]) => pn(O, w)),
365
+ ...Array.isArray(s) ? s : [s]
366
+ ]
367
+ );
368
+ }
369
+ );
370
+ /**
371
+ * @license lucide-react v1.21.0 - ISC
372
+ *
373
+ * This source code is licensed under the ISC license.
374
+ * See the LICENSE file in the root directory of this source tree.
375
+ */
376
+ const Oe = (e, n) => {
377
+ const r = Tn(
378
+ ({ className: a, ...l }, s) => pn(Fr, {
379
+ ref: s,
380
+ iconNode: n,
381
+ className: nr(
382
+ `lucide-${Dr(Dn(e))}`,
383
+ `lucide-${e}`,
384
+ a
385
+ ),
386
+ ...l
387
+ })
388
+ );
389
+ return r.displayName = Dn(e), r;
390
+ };
391
+ /**
392
+ * @license lucide-react v1.21.0 - ISC
393
+ *
394
+ * This source code is licensed under the ISC license.
395
+ * See the LICENSE file in the root directory of this source tree.
396
+ */
397
+ const Hr = [
398
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
399
+ ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
400
+ ], zr = Oe("arrow-right", Hr);
401
+ /**
402
+ * @license lucide-react v1.21.0 - ISC
403
+ *
404
+ * This source code is licensed under the ISC license.
405
+ * See the LICENSE file in the root directory of this source tree.
406
+ */
407
+ const Gr = [
408
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
409
+ ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
410
+ ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
411
+ ], Br = Oe("circle-alert", Gr);
412
+ /**
413
+ * @license lucide-react v1.21.0 - ISC
414
+ *
415
+ * This source code is licensed under the ISC license.
416
+ * See the LICENSE file in the root directory of this source tree.
417
+ */
418
+ const Wr = [
419
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
420
+ ["path", { d: "M16 16s-1.5-2-4-2-4 2-4 2", key: "epbg0q" }],
421
+ ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
422
+ ["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
423
+ ], $r = Oe("frown", Wr);
424
+ /**
425
+ * @license lucide-react v1.21.0 - ISC
426
+ *
427
+ * This source code is licensed under the ISC license.
428
+ * See the LICENSE file in the root directory of this source tree.
429
+ */
430
+ const Yr = [
431
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
432
+ ["path", { d: "M12 16v-4", key: "1dtifu" }],
433
+ ["path", { d: "M12 8h.01", key: "e9boi3" }]
434
+ ], jr = Oe("info", Yr);
435
+ /**
436
+ * @license lucide-react v1.21.0 - ISC
437
+ *
438
+ * This source code is licensed under the ISC license.
439
+ * See the LICENSE file in the root directory of this source tree.
440
+ */
441
+ const Kr = [
442
+ ["path", { d: "M12 19v3", key: "npa21l" }],
443
+ ["path", { d: "M15 9.34V5a3 3 0 0 0-5.68-1.33", key: "1gzdoj" }],
444
+ ["path", { d: "M16.95 16.95A7 7 0 0 1 5 12v-2", key: "cqa7eg" }],
445
+ ["path", { d: "M18.89 13.23A7 7 0 0 0 19 12v-2", key: "16hl24" }],
446
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }],
447
+ ["path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12", key: "r2i35w" }]
448
+ ], Vr = Oe("mic-off", Kr);
449
+ /**
450
+ * @license lucide-react v1.21.0 - ISC
451
+ *
452
+ * This source code is licensed under the ISC license.
453
+ * See the LICENSE file in the root directory of this source tree.
454
+ */
455
+ const qr = [
456
+ ["path", { d: "M12 19v3", key: "npa21l" }],
457
+ ["path", { d: "M19 10v2a7 7 0 0 1-14 0v-2", key: "1vc78b" }],
458
+ ["rect", { x: "9", y: "2", width: "6", height: "13", rx: "3", key: "s6n7sd" }]
459
+ ], Xr = Oe("mic", qr);
460
+ /**
461
+ * @license lucide-react v1.21.0 - ISC
462
+ *
463
+ * This source code is licensed under the ISC license.
464
+ * See the LICENSE file in the root directory of this source tree.
465
+ */
466
+ const Zr = [
467
+ [
468
+ "path",
469
+ {
470
+ d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
471
+ key: "1i5ecw"
472
+ }
473
+ ],
474
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
475
+ ], Jr = Oe("settings", Zr);
476
+ /**
477
+ * @license lucide-react v1.21.0 - ISC
478
+ *
479
+ * This source code is licensed under the ISC license.
480
+ * See the LICENSE file in the root directory of this source tree.
481
+ */
482
+ const Qr = [
483
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
484
+ ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
485
+ ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
486
+ ["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
487
+ ], eo = Oe("smile", Qr);
488
+ /**
489
+ * @license lucide-react v1.21.0 - ISC
490
+ *
491
+ * This source code is licensed under the ISC license.
492
+ * See the LICENSE file in the root directory of this source tree.
493
+ */
494
+ const to = [
495
+ [
496
+ "path",
497
+ {
498
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
499
+ key: "wmoenq"
500
+ }
501
+ ],
502
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
503
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
504
+ ], no = Oe("triangle-alert", to);
505
+ /**
506
+ * @license lucide-react v1.21.0 - ISC
507
+ *
508
+ * This source code is licensed under the ISC license.
509
+ * See the LICENSE file in the root directory of this source tree.
510
+ */
511
+ const ro = [
512
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
513
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
514
+ ], oo = Oe("x", ro);
515
+ function ao(e, n) {
516
+ if (n) {
517
+ n(e);
518
+ return;
519
+ }
520
+ /^https?:\/\//.test(e) ? window.open(e, "_blank", "noopener,noreferrer") : window.location.href = e;
521
+ }
522
+ const rr = ({
523
+ isOpen: e,
524
+ onClose: n,
525
+ anchorRef: r,
526
+ items: a,
527
+ onNavigate: l,
528
+ className: s
529
+ }) => {
530
+ const u = x(null);
531
+ return V(() => {
532
+ if (!e) return;
533
+ const m = (p) => {
534
+ u.current && !u.current.contains(p.target) && r.current && !r.current.contains(p.target) && n();
535
+ }, h = (p) => {
536
+ p.key === "Escape" && n();
537
+ };
538
+ return document.addEventListener("mousedown", m), document.addEventListener("keydown", h), () => {
539
+ document.removeEventListener("mousedown", m), document.removeEventListener("keydown", h);
540
+ };
541
+ }, [e, n, r]), e ? /* @__PURE__ */ i(
542
+ "div",
543
+ {
544
+ ref: u,
545
+ className: _e("ask-arbor-settings", s),
546
+ role: "menu",
547
+ "aria-label": "Settings menu",
548
+ children: a.map((m, h) => /* @__PURE__ */ S(
549
+ "a",
550
+ {
551
+ href: m.url,
552
+ className: "ask-arbor-settings__item",
553
+ role: "menuitem",
554
+ onClick: (p) => {
555
+ p.preventDefault(), n(), ao(m.url, l);
556
+ },
557
+ children: [
558
+ m.icon,
559
+ /* @__PURE__ */ i("span", { className: "ask-arbor-settings__label", children: m.label })
560
+ ]
561
+ },
562
+ `${m.label}-${h}`
563
+ ))
564
+ }
565
+ ) : null;
566
+ };
567
+ rr.displayName = "AskArborSettings";
568
+ function so(e) {
569
+ const n = Math.floor(e / 60), r = e % 60;
570
+ return `${n}:${r.toString().padStart(2, "0")}`;
571
+ }
572
+ const or = Tn(
573
+ ({
574
+ value: e,
575
+ onChange: n,
576
+ onKeyDown: r,
577
+ placeholder: a = "Explain what you need in your own words...",
578
+ onSubmit: l,
579
+ onSettingsClick: s,
580
+ onMicClick: u,
581
+ onStopClick: m,
582
+ menuContent: h,
583
+ onNavigate: p,
584
+ isProcessing: T = !1,
585
+ speechEngaged: A = !1,
586
+ showMicButton: _ = !0,
587
+ ariaLabel: E = "Chat panel input",
588
+ disclaimerText: k = "Ask Arbor can occasionally be wrong. Please check any important information.",
589
+ showDisclaimer: O = !1
590
+ }, w) => {
591
+ const N = x(null), H = x(null), [pe, z] = M(0), [K, U] = M(!1);
592
+ V(() => {
593
+ if (!A) {
594
+ z(0);
595
+ return;
596
+ }
597
+ z(0);
598
+ const G = setInterval(() => {
599
+ z((de) => de + 1);
600
+ }, 1e3);
601
+ return () => clearInterval(G);
602
+ }, [A]), wr(w, () => N.current);
603
+ const q = !T && !A && e.trim().length > 0, me = A, J = Qn(
604
+ () => (h ?? []).map((G) => ({
605
+ label: G.label,
606
+ icon: /* @__PURE__ */ i(
607
+ vt,
608
+ {
609
+ name: G.icon,
610
+ size: 12
611
+ }
612
+ ),
613
+ url: G.url
614
+ })),
615
+ [h]
616
+ );
617
+ return /* @__PURE__ */ S("div", { className: "ask-arbor-input", children: [
618
+ /* @__PURE__ */ S("div", { className: "ask-arbor-input__frame", children: [
619
+ /* @__PURE__ */ i("div", { className: "ask-arbor-input__input-row", children: /* @__PURE__ */ i(
620
+ "textarea",
621
+ {
622
+ ref: N,
623
+ className: "ask-arbor-input__textarea",
624
+ value: e,
625
+ onChange: (G) => n(G.target.value),
626
+ onKeyDown: r,
627
+ placeholder: A ? "" : a,
628
+ "aria-label": E,
629
+ disabled: T || A,
630
+ rows: 1,
631
+ tabIndex: A ? -1 : void 0,
632
+ readOnly: A
633
+ }
634
+ ) }),
635
+ /* @__PURE__ */ i("div", { className: "ask-arbor-input__bottom-actions", children: /* @__PURE__ */ S("div", { className: "ask-arbor-input__actions-right", children: [
636
+ A && /* @__PURE__ */ i("span", { className: "ask-arbor-input__timer", children: so(pe) }),
637
+ J.length > 0 && /* @__PURE__ */ S("div", { className: "ask-arbor-input__settings-wrap", children: [
638
+ /* @__PURE__ */ i(
639
+ "button",
640
+ {
641
+ ref: H,
642
+ type: "button",
643
+ className: _e(
644
+ "ask-arbor-input__btn",
645
+ "ask-arbor-input__btn--settings",
646
+ {
647
+ "ask-arbor-input__btn--settings-open": K
648
+ }
649
+ ),
650
+ onClick: () => {
651
+ U(
652
+ (G) => !G
653
+ ), s == null || s();
654
+ },
655
+ "aria-label": "Settings",
656
+ "aria-expanded": K,
657
+ "aria-haspopup": "menu",
658
+ children: /* @__PURE__ */ i(
659
+ Jr,
660
+ {
661
+ size: 12,
662
+ stroke: "#000000"
663
+ }
664
+ )
665
+ }
666
+ ),
667
+ /* @__PURE__ */ i(
668
+ rr,
669
+ {
670
+ isOpen: K,
671
+ onClose: () => U(!1),
672
+ anchorRef: H,
673
+ items: J,
674
+ onNavigate: p
675
+ }
676
+ )
677
+ ] }),
678
+ _ && u && !me && /* @__PURE__ */ i(
679
+ "button",
680
+ {
681
+ type: "button",
682
+ className: _e(
683
+ "ask-arbor-input__btn",
684
+ "ask-arbor-input__btn--mic"
685
+ ),
686
+ onClick: u,
687
+ "aria-label": "speak with agent",
688
+ disabled: A || T,
689
+ children: /* @__PURE__ */ i(Xr, { size: 12, stroke: "#3C3735" })
690
+ }
691
+ ),
692
+ me && m ? /* @__PURE__ */ S(
693
+ "button",
694
+ {
695
+ type: "button",
696
+ className: "ask-arbor-input__btn ask-arbor-input__btn--stop",
697
+ onClick: m,
698
+ "aria-label": "Stop",
699
+ children: [
700
+ /* @__PURE__ */ i(Vr, { size: 12, stroke: "#FFFFFF" }),
701
+ "Stop"
702
+ ]
703
+ }
704
+ ) : /* @__PURE__ */ i(
705
+ "button",
706
+ {
707
+ type: "button",
708
+ className: "ask-arbor-input__btn ask-arbor-input__btn--submit",
709
+ onClick: l,
710
+ disabled: !q,
711
+ "aria-label": "submit message",
712
+ children: /* @__PURE__ */ i(
713
+ zr,
714
+ {
715
+ size: 12,
716
+ stroke: "#FFFFFF",
717
+ strokeWidth: 2.5
718
+ }
719
+ )
720
+ }
721
+ )
722
+ ] }) })
723
+ ] }),
724
+ O && /* @__PURE__ */ i("p", { className: "ask-arbor-input__disclaimer", children: k })
725
+ ] });
726
+ }
727
+ );
728
+ or.displayName = "AskArborInput";
729
+ const jt = "AGENT", ht = "USER", mn = "INFO", Kt = "WARNING", ve = "ERROR", on = "up", Mn = "down", xn = 10, io = ({
730
+ message: e,
731
+ onRate: n,
732
+ upRatingPopupUrl: r,
733
+ downRatingPopupUrl: a,
734
+ onRatingPopupOpen: l
735
+ }) => {
736
+ const [s, u] = M(null), m = (p) => {
737
+ const T = p === on ? r : a;
738
+ T != null && T.trim() && (l ? l(T.trim()) : window.open(T.trim(), "_blank", "noopener,noreferrer"));
739
+ }, h = (p) => {
740
+ u(p), n(p), m(p);
741
+ };
742
+ return /* @__PURE__ */ S("div", { className: "chat-message__feedback", children: [
743
+ /* @__PURE__ */ i("span", { className: "chat-message__feedback-question", children: "How did Ask Arbor do?" }),
744
+ /* @__PURE__ */ S("div", { className: "chat-message__feedback-buttons", children: [
745
+ /* @__PURE__ */ S(
746
+ "button",
747
+ {
748
+ type: "button",
749
+ "aria-label": "Rate message as good response",
750
+ title: "Good response",
751
+ className: _e(
752
+ "chat-message__feedback-button",
753
+ "chat-message__feedback-button--up",
754
+ {
755
+ "chat-message__feedback-button--selected": s === on
756
+ }
757
+ ),
758
+ onClick: () => h(on),
759
+ children: [
760
+ /* @__PURE__ */ i(
761
+ eo,
762
+ {
763
+ size: xn,
764
+ strokeWidth: 1.5,
765
+ className: "chat-message__feedback-button-icon",
766
+ "aria-hidden": !0
767
+ }
768
+ ),
769
+ /* @__PURE__ */ i("span", { className: "chat-message__feedback-button-text", children: "Nailed it" })
770
+ ]
771
+ }
772
+ ),
773
+ /* @__PURE__ */ S(
774
+ "button",
775
+ {
776
+ type: "button",
777
+ "aria-label": "Rate message as bad response",
778
+ title: "Bad response",
779
+ className: _e(
780
+ "chat-message__feedback-button",
781
+ "chat-message__feedback-button--down",
782
+ {
783
+ "chat-message__feedback-button--selected": s === Mn
784
+ }
785
+ ),
786
+ onClick: () => h(Mn),
787
+ children: [
788
+ /* @__PURE__ */ i(
789
+ $r,
790
+ {
791
+ size: xn,
792
+ strokeWidth: 1.5,
793
+ className: "chat-message__feedback-button-icon",
794
+ "aria-hidden": !0
795
+ }
796
+ ),
797
+ /* @__PURE__ */ i("span", { className: "chat-message__feedback-button-text", children: "Missed the mark" })
798
+ ]
799
+ }
800
+ )
801
+ ] })
802
+ ] });
803
+ }, co = ({
804
+ id: e,
805
+ text: n,
806
+ type: r,
807
+ onRate: a,
808
+ ratingPopupUrls: l = {},
809
+ chatId: s,
810
+ showRating: u = !1,
811
+ followUpPrompts: m,
812
+ onFollowUpPromptClick: h,
813
+ processCanvasReferences: p,
814
+ isFallbackMessage: T,
815
+ onRatingPopupOpen: A,
816
+ children: _
817
+ }) => {
818
+ const E = r === jt, k = /* @__PURE__ */ S(we, { children: [
819
+ /* @__PURE__ */ S(
820
+ "div",
821
+ {
822
+ className: _e("chat-message", {
823
+ "chat-message--user": r === ht,
824
+ "chat-message--agent": r === jt,
825
+ "chat-message--info": r === mn,
826
+ "chat-message--error": r === ve,
827
+ "chat-message--warning": r === Kt
828
+ }),
829
+ children: [
830
+ r === mn && /* @__PURE__ */ i(
831
+ jr,
832
+ {
833
+ className: "chat-message__icon",
834
+ "aria-label": "Information",
835
+ size: 20
836
+ }
837
+ ),
838
+ r === Kt && /* @__PURE__ */ i(
839
+ no,
840
+ {
841
+ className: "chat-message__icon",
842
+ "aria-label": "Warning",
843
+ size: 20
844
+ }
845
+ ),
846
+ r === ve && /* @__PURE__ */ i(
847
+ Br,
848
+ {
849
+ className: "chat-message__icon",
850
+ "aria-label": "Error",
851
+ size: 20
852
+ }
853
+ ),
854
+ _ ?? /* @__PURE__ */ i(
855
+ "span",
856
+ {
857
+ dangerouslySetInnerHTML: {
858
+ __html: p(n)
859
+ }
860
+ }
861
+ )
862
+ ]
863
+ }
864
+ ),
865
+ E && /* @__PURE__ */ S("div", { className: "chat-message__footer-actions", children: [
866
+ /* @__PURE__ */ i("div", { className: "chat-message__footer-icons", children: u && a && s && /* @__PURE__ */ i(
867
+ io,
868
+ {
869
+ upRatingPopupUrl: l.up,
870
+ downRatingPopupUrl: l.down,
871
+ message: { id: e, type: r, text: n },
872
+ onRate: (O) => a(O, e),
873
+ onRatingPopupOpen: A
874
+ }
875
+ ) }),
876
+ /* @__PURE__ */ i("div", { className: "chat-message__follow-up-prompts", children: m && m.length > 0 && !T && /* @__PURE__ */ i("ul", { className: "chat-message__follow-up-prompts-list", children: m.map(
877
+ (O, w) => /* @__PURE__ */ i(
878
+ "li",
879
+ {
880
+ children: /* @__PURE__ */ i(
881
+ "button",
882
+ {
883
+ type: "button",
884
+ className: "chat-message__follow-up-prompt",
885
+ onClick: () => h == null ? void 0 : h(
886
+ O
887
+ ),
888
+ children: O
889
+ }
890
+ )
891
+ },
892
+ `follow-up-prompt-${w}`
893
+ )
894
+ ) }) })
895
+ ] })
896
+ ] });
897
+ return /* @__PURE__ */ i(
898
+ "li",
899
+ {
900
+ className: _e("chat-message-container", {
901
+ "chat-message-container--user": r === ht,
902
+ "chat-message-container--agent": E
903
+ }),
904
+ children: E ? /* @__PURE__ */ i("div", { className: "chat-message-container__content", children: k }) : k
905
+ }
906
+ );
907
+ }, lo = "Not authorised. Your session could have expired or is invalid. Please refresh the page and try again.", uo = "You do not have permission to use this feature. Please contact your administrator if you need access.", fo = "The chat service could not be found. Please check your configuration and try again.", po = "It looks like this request took too long to complete. Please try again.", mo = "Whoops! Too many requests. Please wait a moment and try again.", ho = "The chat service is temporarily unavailable. Please try again later.", _o = "Unable to reach the chat service. Please check your connection and try again.", ar = "Something went wrong. Please try again later.", go = "Something went wrong while trying to get a new agent message. Please try again later.", Pn = "keyboard-shortcut-menu-portal";
908
+ function bo() {
909
+ let e = document.getElementById(Pn);
910
+ return e || (e = document.createElement("div"), e.id = Pn, e.style.cssText = "position:fixed;left:0;top:0;z-index:19950;pointer-events:none;", document.body.appendChild(e)), e;
911
+ }
912
+ const Vt = 200;
913
+ function yo(e) {
914
+ const n = window.innerHeight, r = e.top + e.height > n - Vt, a = e.top < Vt;
915
+ return r ? "above" : a ? "below" : "above";
916
+ }
917
+ function To(e) {
918
+ const n = yo(e), r = 8;
919
+ return n === "below" ? {
920
+ left: e.left,
921
+ width: e.width,
922
+ top: e.bottom + r,
923
+ placement: "below"
924
+ } : {
925
+ left: e.left,
926
+ width: e.width,
927
+ bottom: window.innerHeight - e.top + r,
928
+ placement: "above"
929
+ };
930
+ }
931
+ function Un(e, n) {
932
+ if (n) {
933
+ n(e);
934
+ return;
935
+ }
936
+ /^https?:\/\//.test(e) ? window.open(e, "_blank", "noopener,noreferrer") : window.location.href = e;
937
+ }
938
+ const Eo = ({
939
+ anchorRef: e,
940
+ ...n
941
+ }) => {
942
+ const [r, a] = M(
943
+ null
944
+ );
945
+ if (er(() => {
946
+ const s = () => {
947
+ const p = e.current;
948
+ if (!p) return;
949
+ const T = p.getBoundingClientRect();
950
+ a(To(T));
951
+ };
952
+ s();
953
+ const u = requestAnimationFrame(() => s()), m = () => s(), h = () => s();
954
+ return document.addEventListener("scroll", m, !0), window.addEventListener("resize", h), () => {
955
+ cancelAnimationFrame(u), document.removeEventListener("scroll", m, !0), window.removeEventListener("resize", h);
956
+ };
957
+ }, [e]), !r) return null;
958
+ const l = {
959
+ position: "fixed",
960
+ left: r.left,
961
+ width: r.width,
962
+ pointerEvents: "auto"
963
+ };
964
+ return r.placement === "below" ? l.top = r.top : l.bottom = r.bottom, Nr(
965
+ /* @__PURE__ */ i(sr, { ...n, portalStyle: l }),
966
+ bo()
967
+ );
968
+ }, sr = (e) => {
969
+ const {
970
+ menuItems: n = [],
971
+ onSelectItem: r,
972
+ onClose: a,
973
+ hideReferenceFromList: l = !1,
974
+ anchorRef: s,
975
+ portalStyle: u,
976
+ onNavigate: m
977
+ } = e, [h, p] = M(0), [T, A] = M(""), [_, E] = M(n), k = x(null), O = x(null), w = x(null), [N, H] = M(!1), [pe, z] = M(!1), K = u ? u.top != null : N, U = u ? !0 : pe;
978
+ V(() => {
979
+ p(0), A("");
980
+ }, []), V(() => {
981
+ u && setTimeout(() => {
982
+ var b;
983
+ return (b = w.current) == null ? void 0 : b.focus();
984
+ }, 0);
985
+ }, [u]), V(() => {
986
+ if (u || s || !k.current) return;
987
+ const b = k.current.getBoundingClientRect(), L = window.innerHeight, B = b.top, re = B + b.height > L - Vt, D = B < Vt;
988
+ H(re ? !1 : !!D), z(!0), setTimeout(() => {
989
+ var W;
990
+ return (W = w.current) == null ? void 0 : W.focus();
991
+ }, 0);
992
+ }, [s]), V(() => {
993
+ if (O.current) {
994
+ const b = O.current.querySelector(
995
+ ".keyboard-shortcut-menu__items"
996
+ ), L = b == null ? void 0 : b.querySelector(
997
+ ".keyboard-shortcut-menu__item--selected"
998
+ );
999
+ L && L.scrollIntoView({
1000
+ behavior: "smooth",
1001
+ block: "nearest"
1002
+ });
1003
+ }
1004
+ }, [h]), V(() => {
1005
+ E(
1006
+ T ? n.filter(
1007
+ (b) => b.reference.toLowerCase().includes(T.toLowerCase()) || b.description.toLowerCase().includes(T.toLowerCase())
1008
+ ) : n
1009
+ );
1010
+ }, [T, n]);
1011
+ const q = (b) => {
1012
+ var L;
1013
+ r && _[b] && !_[b].link && r(_[b]), a && !((L = _[b]) != null && L.link) && a();
1014
+ };
1015
+ V(() => {
1016
+ const b = (B) => {
1017
+ B.key === "Escape" && a && (B.preventDefault(), a());
1018
+ }, L = (B) => {
1019
+ k.current && !k.current.contains(B.target) && a && a();
1020
+ };
1021
+ return document.addEventListener("keydown", b), document.addEventListener("mousedown", L), () => {
1022
+ document.removeEventListener("keydown", b), document.removeEventListener("mousedown", L);
1023
+ };
1024
+ }, [a]);
1025
+ const me = (b) => {
1026
+ switch (b.key) {
1027
+ case "ArrowDown":
1028
+ b.preventDefault(), p(
1029
+ (L) => L < _.length - 1 ? L + 1 : L
1030
+ );
1031
+ break;
1032
+ case "ArrowUp":
1033
+ b.preventDefault(), p((L) => L > 0 ? L - 1 : 0);
1034
+ break;
1035
+ case "Enter":
1036
+ b.preventDefault(), _[h] && (_[h].link ? Un(
1037
+ _[h].link.replace(
1038
+ /\/\?/g,
1039
+ ""
1040
+ ),
1041
+ m
1042
+ ) : q(h));
1043
+ break;
1044
+ case "Escape":
1045
+ b.preventDefault(), a && a();
1046
+ break;
1047
+ }
1048
+ }, J = (b) => {
1049
+ A(b), p(0);
1050
+ }, G = (b, L) => {
1051
+ const B = L === h, re = b.icon ? /* @__PURE__ */ S(we, { children: [
1052
+ /* @__PURE__ */ i(vt, { name: b.icon, size: 12 }),
1053
+ /* @__PURE__ */ i("span", { className: "keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main", children: b.description })
1054
+ ] }) : /* @__PURE__ */ i(we, { children: l ? /* @__PURE__ */ i(
1055
+ "span",
1056
+ {
1057
+ "data-testid": "keyboard-shortcut-menu-item",
1058
+ className: "keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",
1059
+ children: b.description
1060
+ }
1061
+ ) : /* @__PURE__ */ S(we, { children: [
1062
+ /* @__PURE__ */ i("span", { className: "keyboard-shortcut-menu__item-reference keyboard-shortcut-menu__item-main", children: b.reference }),
1063
+ /* @__PURE__ */ i("span", { className: "keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-secondary", children: b.description })
1064
+ ] }) });
1065
+ if (b.link) {
1066
+ const D = b.link.replace(/\/\?/g, "");
1067
+ return /* @__PURE__ */ i("li", { role: "menuitem", children: /* @__PURE__ */ i(
1068
+ "a",
1069
+ {
1070
+ href: D,
1071
+ className: _e(
1072
+ "keyboard-shortcut-menu__item-main keyboard-shortcut-menu__item",
1073
+ {
1074
+ "keyboard-shortcut-menu__item--selected": B,
1075
+ "keyboard-shortcut-menu__item--with-icon": !!b.icon
1076
+ }
1077
+ ),
1078
+ onClick: (W) => {
1079
+ W.preventDefault(), Un(D, m), a == null || a();
1080
+ },
1081
+ children: re
1082
+ }
1083
+ ) }, b.reference);
1084
+ }
1085
+ return /* @__PURE__ */ i(
1086
+ "li",
1087
+ {
1088
+ role: "menuitem",
1089
+ className: _e("keyboard-shortcut-menu__item", {
1090
+ "keyboard-shortcut-menu__item--selected": B,
1091
+ "keyboard-shortcut-menu__item--with-icon": !!b.icon
1092
+ }),
1093
+ onClick: () => {
1094
+ r && r(b), a && a();
1095
+ },
1096
+ "aria-selected": B,
1097
+ children: re
1098
+ },
1099
+ b.reference
1100
+ );
1101
+ }, de = /* @__PURE__ */ i(
1102
+ "div",
1103
+ {
1104
+ className: _e("keyboard-shortcut-menu", {
1105
+ "keyboard-shortcut-menu-below": K,
1106
+ "keyboard-shortcut-menu-hidden": !U
1107
+ }),
1108
+ onKeyDown: me,
1109
+ tabIndex: 0,
1110
+ "aria-label": "Keyboard shortcut menu",
1111
+ "data-testid": "keyboard-shortcut-menu",
1112
+ ref: k,
1113
+ children: /* @__PURE__ */ S("div", { className: "keyboard-shortcut-menu__content", ref: O, children: [
1114
+ /* @__PURE__ */ S("div", { className: "keyboard-shortcut-menu__header", children: [
1115
+ /* @__PURE__ */ i("div", { className: "keyboard-shortcut-menu__search", children: /* @__PURE__ */ i(
1116
+ "input",
1117
+ {
1118
+ type: "text",
1119
+ value: T,
1120
+ onChange: (b) => J(b.target.value),
1121
+ placeholder: "Search...",
1122
+ autoFocus: !0,
1123
+ ref: w
1124
+ }
1125
+ ) }),
1126
+ a && /* @__PURE__ */ i(
1127
+ "button",
1128
+ {
1129
+ type: "button",
1130
+ className: "keyboard-shortcut-menu__close",
1131
+ onClick: a,
1132
+ "aria-label": "Close menu",
1133
+ children: /* @__PURE__ */ i(
1134
+ oo,
1135
+ {
1136
+ size: 12,
1137
+ className: "keyboard-shortcut-menu__close-icon"
1138
+ }
1139
+ )
1140
+ }
1141
+ )
1142
+ ] }),
1143
+ /* @__PURE__ */ i(
1144
+ "ul",
1145
+ {
1146
+ className: "keyboard-shortcut-menu__items",
1147
+ role: "menu",
1148
+ "aria-label": "Menu options",
1149
+ children: _.length === 0 ? /* @__PURE__ */ i(
1150
+ "li",
1151
+ {
1152
+ className: "keyboard-shortcut-menu__no-results",
1153
+ role: "menuitem",
1154
+ children: "No results found"
1155
+ }
1156
+ ) : _.map(
1157
+ (b, L) => G(b, L)
1158
+ )
1159
+ }
1160
+ )
1161
+ ] })
1162
+ }
1163
+ );
1164
+ return s && !u ? /* @__PURE__ */ i(
1165
+ Eo,
1166
+ {
1167
+ anchorRef: s,
1168
+ menuItems: n,
1169
+ onSelectItem: r,
1170
+ onClose: a,
1171
+ hideReferenceFromList: e.hideReferenceFromList,
1172
+ title: e.title,
1173
+ onNavigate: m
1174
+ }
1175
+ ) : u ? /* @__PURE__ */ i("div", { style: u, children: de }) : de;
1176
+ }, Fn = ({ className: e }) => /* @__PURE__ */ i(
1177
+ "div",
1178
+ {
1179
+ className: _e("loading-spinner", e),
1180
+ "aria-label": "Loading",
1181
+ role: "img",
1182
+ children: /* @__PURE__ */ S("div", { className: "loading-spinner__inner", role: "presentation", children: [
1183
+ /* @__PURE__ */ i(
1184
+ "div",
1185
+ {
1186
+ className: "loading-spinner__circle loading-spinner__circle-left",
1187
+ role: "presentation"
1188
+ }
1189
+ ),
1190
+ /* @__PURE__ */ i(
1191
+ "div",
1192
+ {
1193
+ className: "loading-spinner__circle loading-spinner__circle-top",
1194
+ role: "presentation"
1195
+ }
1196
+ ),
1197
+ /* @__PURE__ */ i(
1198
+ "div",
1199
+ {
1200
+ className: "loading-spinner__circle loading-spinner__circle-right",
1201
+ role: "presentation"
1202
+ }
1203
+ ),
1204
+ /* @__PURE__ */ i(
1205
+ "div",
1206
+ {
1207
+ className: "loading-spinner__circle loading-spinner__circle-bottom",
1208
+ role: "presentation"
1209
+ }
1210
+ )
1211
+ ] })
1212
+ }
1213
+ ), Ao = 4e3, So = 500, wo = 8e3, an = [
1214
+ "I'm working on it…",
1215
+ "Generating insights…",
1216
+ "Piecing things together…",
1217
+ "Processing your request…",
1218
+ "Refining the details…",
1219
+ "Just a moment…",
1220
+ "Organising the information…",
1221
+ "Bringing it all together…",
1222
+ "Gathering facts…",
1223
+ "Crafting a response…",
1224
+ "Thinking things through…",
1225
+ "Preparing results…",
1226
+ "Double-checking my output…",
1227
+ "Reviewing the options…",
1228
+ "Gathering data…",
1229
+ "Looking at data…",
1230
+ "Digging deeper…",
1231
+ "Reaching a conclusion…",
1232
+ "Checking the data…",
1233
+ "Thinking…",
1234
+ "Putting ideas together…",
1235
+ "Cross-checking information…",
1236
+ "Filling in the gaps…",
1237
+ "Finding the answers…",
1238
+ "Organising my thoughts…",
1239
+ "On it…",
1240
+ "Working on my response…",
1241
+ "Building your response…",
1242
+ "Exploring the possibilities…",
1243
+ "Completing the task…",
1244
+ "Shaping the outcome…",
1245
+ "Fine-tuning the details…",
1246
+ "Crunching the data…",
1247
+ "Looking up insights…",
1248
+ "Composing an answer…",
1249
+ "Pulling it all together…",
1250
+ "Preparing a solution…",
1251
+ "Making connections…",
1252
+ "Polishing the results…",
1253
+ "Steady progress…",
1254
+ "Testing assumptions…",
1255
+ "Checking possibilities…",
1256
+ "Sifting through some ideas…",
1257
+ "Organising concepts…",
1258
+ "Analysing your query…",
1259
+ "Analysing results…",
1260
+ "Working through the details…"
1261
+ ], No = ({
1262
+ loadingPhrase: e,
1263
+ showSpinnerAsIcon: n = !0,
1264
+ showNotifyLaterButton: r = !1,
1265
+ onNotifyLater: a,
1266
+ onNotificationRegisteredGotIt: l
1267
+ }) => {
1268
+ const s = () => Math.floor(Math.random() * an.length), u = x(null), [m, h] = M(
1269
+ e || an[s()]
1270
+ ), [p, T] = M("fade-in"), [A, _] = M(!1), [E, k] = M(!1);
1271
+ V(() => {
1272
+ r || k(!1);
1273
+ }, [r]), V(() => {
1274
+ if (!r || !a)
1275
+ return;
1276
+ const N = setTimeout(() => {
1277
+ _(!0);
1278
+ }, wo);
1279
+ return () => {
1280
+ clearTimeout(N);
1281
+ };
1282
+ }, [r, a]);
1283
+ const O = async () => {
1284
+ if (!a)
1285
+ return;
1286
+ await a() && k(!0);
1287
+ }, w = () => {
1288
+ k(!1), l == null || l();
1289
+ };
1290
+ return V(() => {
1291
+ let N = null;
1292
+ return e ? (h(e), T("fade-in")) : N = setInterval(() => {
1293
+ T("fade-out"), setTimeout(() => {
1294
+ let H;
1295
+ do
1296
+ H = s();
1297
+ while (H === u.current);
1298
+ u.current = H, h(an[H]), T("fade-in");
1299
+ }, So);
1300
+ }, Ao), () => {
1301
+ N && clearInterval(N);
1302
+ };
1303
+ }, [e]), /* @__PURE__ */ S(
1304
+ "li",
1305
+ {
1306
+ "aria-label": "Loading response",
1307
+ className: "chat-panel__loading-container",
1308
+ "data-testid": "loading-widget",
1309
+ children: [
1310
+ /* @__PURE__ */ S("div", { className: "chat-panel__loading-content", children: [
1311
+ n ? /* @__PURE__ */ i(Fn, { className: "chat-panel__loading-spinner" }) : /* @__PURE__ */ i("span", { className: "chat-panel__loading-spinner-container", children: /* @__PURE__ */ i(Fn, { className: "chat-panel__loading-spinner" }) }),
1312
+ /* @__PURE__ */ i("span", { className: `chat-panel__loading-phrase ${p}`, children: m })
1313
+ ] }),
1314
+ r && a && A && /* @__PURE__ */ i("div", { className: "chat-panel__notify-later", children: E ? /* @__PURE__ */ S(we, { children: [
1315
+ /* @__PURE__ */ i("p", { className: "chat-panel__notify-later-message", children: "We'll notify you in the notifications panel on the left of your MIS." }),
1316
+ /* @__PURE__ */ i(
1317
+ "button",
1318
+ {
1319
+ type: "button",
1320
+ className: "chat-panel__notify-later-btn",
1321
+ onClick: w,
1322
+ "aria-label": "Got it",
1323
+ children: "Got it"
1324
+ }
1325
+ )
1326
+ ] }) : /* @__PURE__ */ S(we, { children: [
1327
+ /* @__PURE__ */ i("p", { className: "chat-panel__notify-later-message", children: "This one's taking a bit longer than usual" }),
1328
+ /* @__PURE__ */ i(
1329
+ "button",
1330
+ {
1331
+ type: "button",
1332
+ className: "chat-panel__notify-later-btn",
1333
+ onClick: O,
1334
+ "aria-label": "Let me know when it's done",
1335
+ children: "Let me know when it's done"
1336
+ }
1337
+ )
1338
+ ] }) })
1339
+ ]
1340
+ }
1341
+ );
1342
+ };
1343
+ function ko(e) {
1344
+ V(e, []);
1345
+ }
1346
+ function Ro() {
1347
+ const e = x(!1);
1348
+ return V(() => (e.current = !0, () => {
1349
+ e.current = !1;
1350
+ }), []), e;
1351
+ }
1352
+ function Io() {
1353
+ return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).substring(2) + Date.now().toString(36);
1354
+ }
1355
+ function Co(e, n = 0) {
1356
+ if (typeof e == "number" && e > 0) return e;
1357
+ if (typeof e == "string") {
1358
+ const r = parseInt(e, 10);
1359
+ if (!isNaN(r) && r > 0) return r;
1360
+ }
1361
+ return n;
1362
+ }
1363
+ const vo = /\*\*(.+?)\*\*/g;
1364
+ function Oo(e) {
1365
+ return e.replace(vo, "<strong>$1</strong>");
1366
+ }
1367
+ /*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
1368
+ function Hn(e, n) {
1369
+ (n == null || n > e.length) && (n = e.length);
1370
+ for (var r = 0, a = Array(n); r < n; r++) a[r] = e[r];
1371
+ return a;
1372
+ }
1373
+ function Lo(e) {
1374
+ if (Array.isArray(e)) return e;
1375
+ }
1376
+ function Do(e, n) {
1377
+ var r = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
1378
+ if (r != null) {
1379
+ var a, l, s, u, m = [], h = !0, p = !1;
1380
+ try {
1381
+ if (s = (r = r.call(e)).next, n !== 0) for (; !(h = (a = s.call(r)).done) && (m.push(a.value), m.length !== n); h = !0) ;
1382
+ } catch (T) {
1383
+ p = !0, l = T;
1384
+ } finally {
1385
+ try {
1386
+ if (!h && r.return != null && (u = r.return(), Object(u) !== u)) return;
1387
+ } finally {
1388
+ if (p) throw l;
1389
+ }
1390
+ }
1391
+ return m;
1392
+ }
1393
+ }
1394
+ function Mo() {
1395
+ throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1396
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
1397
+ }
1398
+ function xo(e, n) {
1399
+ return Lo(e) || Do(e, n) || Po(e, n) || Mo();
1400
+ }
1401
+ function Po(e, n) {
1402
+ if (e) {
1403
+ if (typeof e == "string") return Hn(e, n);
1404
+ var r = {}.toString.call(e).slice(8, -1);
1405
+ return r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set" ? Array.from(e) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? Hn(e, n) : void 0;
1406
+ }
1407
+ }
1408
+ const ir = Object.entries, zn = Object.setPrototypeOf, Uo = Object.isFrozen, Fo = Object.getPrototypeOf, Ho = Object.getOwnPropertyDescriptor;
1409
+ let se = Object.freeze, ie = Object.seal, mt = Object.create, cr = typeof Reflect < "u" && Reflect, hn = cr.apply, _n = cr.construct;
1410
+ se || (se = function(n) {
1411
+ return n;
1412
+ });
1413
+ ie || (ie = function(n) {
1414
+ return n;
1415
+ });
1416
+ hn || (hn = function(n, r) {
1417
+ for (var a = arguments.length, l = new Array(a > 2 ? a - 2 : 0), s = 2; s < a; s++)
1418
+ l[s - 2] = arguments[s];
1419
+ return n.apply(r, l);
1420
+ });
1421
+ _n || (_n = function(n) {
1422
+ for (var r = arguments.length, a = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
1423
+ a[l - 1] = arguments[l];
1424
+ return new n(...a);
1425
+ });
1426
+ const Nt = Z(Array.prototype.forEach), zo = Z(Array.prototype.lastIndexOf), Gn = Z(Array.prototype.pop), pt = Z(Array.prototype.push), Go = Z(Array.prototype.splice), Be = Array.isArray, Ct = Z(String.prototype.toLowerCase), sn = Z(String.prototype.toString), Bn = Z(String.prototype.match), kt = Z(String.prototype.replace), Wn = Z(String.prototype.indexOf), Bo = Z(String.prototype.trim), Wo = Z(Number.prototype.toString), $o = Z(Boolean.prototype.toString), $n = typeof BigInt > "u" ? null : Z(BigInt.prototype.toString), Yn = typeof Symbol > "u" ? null : Z(Symbol.prototype.toString), ne = Z(Object.prototype.hasOwnProperty), Rt = Z(Object.prototype.toString), ae = Z(RegExp.prototype.test), Qe = Yo(TypeError);
1427
+ function Z(e) {
1428
+ return function(n) {
1429
+ n instanceof RegExp && (n.lastIndex = 0);
1430
+ for (var r = arguments.length, a = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
1431
+ a[l - 1] = arguments[l];
1432
+ return hn(e, n, a);
1433
+ };
1434
+ }
1435
+ function Yo(e) {
1436
+ return function() {
1437
+ for (var n = arguments.length, r = new Array(n), a = 0; a < n; a++)
1438
+ r[a] = arguments[a];
1439
+ return _n(e, r);
1440
+ };
1441
+ }
1442
+ function C(e, n) {
1443
+ let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Ct;
1444
+ if (zn && zn(e, null), !Be(n))
1445
+ return e;
1446
+ let a = n.length;
1447
+ for (; a--; ) {
1448
+ let l = n[a];
1449
+ if (typeof l == "string") {
1450
+ const s = r(l);
1451
+ s !== l && (Uo(n) || (n[a] = s), l = s);
1452
+ }
1453
+ e[l] = !0;
1454
+ }
1455
+ return e;
1456
+ }
1457
+ function jo(e) {
1458
+ for (let n = 0; n < e.length; n++)
1459
+ ne(e, n) || (e[n] = null);
1460
+ return e;
1461
+ }
1462
+ function ue(e) {
1463
+ const n = mt(null);
1464
+ for (const a of ir(e)) {
1465
+ var r = xo(a, 2);
1466
+ const l = r[0], s = r[1];
1467
+ ne(e, l) && (Be(s) ? n[l] = jo(s) : s && typeof s == "object" && s.constructor === Object ? n[l] = ue(s) : n[l] = s);
1468
+ }
1469
+ return n;
1470
+ }
1471
+ function Ko(e) {
1472
+ switch (typeof e) {
1473
+ case "string":
1474
+ return e;
1475
+ case "number":
1476
+ return Wo(e);
1477
+ case "boolean":
1478
+ return $o(e);
1479
+ case "bigint":
1480
+ return $n ? $n(e) : "0";
1481
+ case "symbol":
1482
+ return Yn ? Yn(e) : "Symbol()";
1483
+ case "undefined":
1484
+ return Rt(e);
1485
+ case "function":
1486
+ case "object": {
1487
+ if (e === null)
1488
+ return Rt(e);
1489
+ const n = e, r = Ce(n, "toString");
1490
+ if (typeof r == "function") {
1491
+ const a = r(n);
1492
+ return typeof a == "string" ? a : Rt(a);
1493
+ }
1494
+ return Rt(e);
1495
+ }
1496
+ default:
1497
+ return Rt(e);
1498
+ }
1499
+ }
1500
+ function Ce(e, n) {
1501
+ for (; e !== null; ) {
1502
+ const a = Ho(e, n);
1503
+ if (a) {
1504
+ if (a.get)
1505
+ return Z(a.get);
1506
+ if (typeof a.value == "function")
1507
+ return Z(a.value);
1508
+ }
1509
+ e = Fo(e);
1510
+ }
1511
+ function r() {
1512
+ return null;
1513
+ }
1514
+ return r;
1515
+ }
1516
+ function Vo(e) {
1517
+ try {
1518
+ return ae(e, ""), !0;
1519
+ } catch {
1520
+ return !1;
1521
+ }
1522
+ }
1523
+ const jn = se(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), cn = se(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), ln = se(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), qo = se(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), un = se(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Xo = se(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Kn = se(["#text"]), Vn = se(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]), dn = se(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), qn = se(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), $t = se(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Zo = ie(/{{[\w\W]*|^[\w\W]*}}/g), Jo = ie(/<%[\w\W]*|^[\w\W]*%>/g), Qo = ie(/\${[\w\W]*/g), ea = ie(/^data-[\-\w.\u00B7-\uFFFF]+$/), ta = ie(/^aria-[\-\w]+$/), Xn = ie(
1524
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
1525
+ // eslint-disable-line no-useless-escape
1526
+ ), na = ie(/^(?:\w+script|data):/i), ra = ie(
1527
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
1528
+ // eslint-disable-line no-control-regex
1529
+ ), oa = ie(/^html$/i), aa = ie(/^[a-z][.\w]*(-[.\w]+)+$/i), Zn = ie(/<[/\w!]/g), sa = ie(/<[/\w]/g), ia = ie(/<\/no(script|embed|frames)/i), ca = ie(/\/>/i), Ie = {
1530
+ element: 1,
1531
+ attribute: 2,
1532
+ text: 3,
1533
+ cdataSection: 4,
1534
+ entityReference: 5,
1535
+ // Deprecated
1536
+ entityNode: 6,
1537
+ // Deprecated
1538
+ processingInstruction: 7,
1539
+ comment: 8,
1540
+ document: 9,
1541
+ documentType: 10,
1542
+ documentFragment: 11,
1543
+ notation: 12
1544
+ // Deprecated
1545
+ }, la = function() {
1546
+ return typeof window > "u" ? null : window;
1547
+ }, ua = function(n, r) {
1548
+ if (typeof n != "object" || typeof n.createPolicy != "function")
1549
+ return null;
1550
+ let a = null;
1551
+ const l = "data-tt-policy-suffix";
1552
+ r && r.hasAttribute(l) && (a = r.getAttribute(l));
1553
+ const s = "dompurify" + (a ? "#" + a : "");
1554
+ try {
1555
+ return n.createPolicy(s, {
1556
+ createHTML(u) {
1557
+ return u;
1558
+ },
1559
+ createScriptURL(u) {
1560
+ return u;
1561
+ }
1562
+ });
1563
+ } catch {
1564
+ return console.warn("TrustedTypes policy " + s + " could not be created."), null;
1565
+ }
1566
+ }, Jn = function() {
1567
+ return {
1568
+ afterSanitizeAttributes: [],
1569
+ afterSanitizeElements: [],
1570
+ afterSanitizeShadowDOM: [],
1571
+ beforeSanitizeAttributes: [],
1572
+ beforeSanitizeElements: [],
1573
+ beforeSanitizeShadowDOM: [],
1574
+ uponSanitizeAttribute: [],
1575
+ uponSanitizeElement: [],
1576
+ uponSanitizeShadowNode: []
1577
+ };
1578
+ }, Ge = function(n, r, a, l) {
1579
+ return ne(n, r) && Be(n[r]) ? C(l.base ? ue(l.base) : {}, n[r], l.transform) : a;
1580
+ };
1581
+ function lr() {
1582
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : la();
1583
+ const n = (f) => lr(f);
1584
+ if (n.version = "3.4.11", n.removed = [], !e || !e.document || e.document.nodeType !== Ie.document || !e.Element)
1585
+ return n.isSupported = !1, n;
1586
+ let r = e.document;
1587
+ const a = r, l = a.currentScript;
1588
+ e.DocumentFragment;
1589
+ const s = e.HTMLTemplateElement, u = e.Node, m = e.Element, h = e.NodeFilter, p = e.NamedNodeMap;
1590
+ p === void 0 && (e.NamedNodeMap || e.MozNamedAttrMap), e.HTMLFormElement;
1591
+ const T = e.DOMParser, A = e.trustedTypes, _ = m.prototype, E = Ce(_, "cloneNode"), k = Ce(_, "remove"), O = Ce(_, "nextSibling"), w = Ce(_, "childNodes"), N = Ce(_, "parentNode"), H = Ce(_, "shadowRoot"), pe = Ce(_, "attributes"), z = u && u.prototype ? Ce(u.prototype, "nodeType") : null, K = u && u.prototype ? Ce(u.prototype, "nodeName") : null;
1592
+ if (typeof s == "function") {
1593
+ const f = r.createElement("template");
1594
+ f.content && f.content.ownerDocument && (r = f.content.ownerDocument);
1595
+ }
1596
+ let U, q = "", me, J = !1, G = 0;
1597
+ const de = function() {
1598
+ if (G > 0)
1599
+ throw Qe('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
1600
+ }, b = function(t) {
1601
+ de(), G++;
1602
+ try {
1603
+ return U.createHTML(t);
1604
+ } finally {
1605
+ G--;
1606
+ }
1607
+ }, L = function(t) {
1608
+ de(), G++;
1609
+ try {
1610
+ return U.createScriptURL(t);
1611
+ } finally {
1612
+ G--;
1613
+ }
1614
+ }, B = function() {
1615
+ return J || (me = ua(A, l), J = !0), me;
1616
+ }, re = r, D = re.implementation, W = re.createNodeIterator, he = re.createDocumentFragment, Le = re.getElementsByTagName, xe = a.importNode;
1617
+ let F = Jn();
1618
+ n.isSupported = typeof ir == "function" && typeof N == "function" && D && D.createHTMLDocument !== void 0;
1619
+ const oe = Zo, _t = Jo, Q = Qo, gt = ea, qt = ta, Ot = na, et = ra, We = aa;
1620
+ let Pe = Xn, P = null;
1621
+ const tt = C({}, [...jn, ...cn, ...ln, ...un, ...Kn]);
1622
+ let Y = null;
1623
+ const nt = C({}, [...Vn, ...dn, ...qn, ...$t]);
1624
+ let $ = Object.seal(mt(null, {
1625
+ tagNameCheck: {
1626
+ writable: !0,
1627
+ configurable: !1,
1628
+ enumerable: !0,
1629
+ value: null
1630
+ },
1631
+ attributeNameCheck: {
1632
+ writable: !0,
1633
+ configurable: !1,
1634
+ enumerable: !0,
1635
+ value: null
1636
+ },
1637
+ allowCustomizedBuiltInElements: {
1638
+ writable: !0,
1639
+ configurable: !1,
1640
+ enumerable: !0,
1641
+ value: !1
1642
+ }
1643
+ })), Ne = null, bt = null;
1644
+ const Ee = Object.seal(mt(null, {
1645
+ tagCheck: {
1646
+ writable: !0,
1647
+ configurable: !1,
1648
+ enumerable: !0,
1649
+ value: null
1650
+ },
1651
+ attributeCheck: {
1652
+ writable: !0,
1653
+ configurable: !1,
1654
+ enumerable: !0,
1655
+ value: null
1656
+ }
1657
+ }));
1658
+ let Lt = !0, $e = !0, rt = !1, Ue = !0, Ae = !1, Ye = !0, ke = !1, ot = !1, je = null, Fe = null, at = !1, De = !1, Ke = !1, st = !1, yt = !0, Ve = !1;
1659
+ const it = "user-content-";
1660
+ let Tt = !0, ct = !1, He = {}, ge = null;
1661
+ const qe = C({}, [
1662
+ "annotation-xml",
1663
+ "audio",
1664
+ "colgroup",
1665
+ "desc",
1666
+ "foreignobject",
1667
+ "head",
1668
+ "iframe",
1669
+ "math",
1670
+ "mi",
1671
+ "mn",
1672
+ "mo",
1673
+ "ms",
1674
+ "mtext",
1675
+ "noembed",
1676
+ "noframes",
1677
+ "noscript",
1678
+ "plaintext",
1679
+ "script",
1680
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
1681
+ // the UA (customizable <select>) — including any on* handlers — and the
1682
+ // engine re-mirrors synchronously whenever a removal changes which
1683
+ // option/selectedcontent is current, even inside DOMPurify's inert
1684
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
1685
+ // mirror target ahead of the walk, which the engine refills, looping
1686
+ // forever (DoS) and amplifying output. Dropping its content on removal
1687
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
1688
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
1689
+ "selectedcontent",
1690
+ "style",
1691
+ "svg",
1692
+ "template",
1693
+ "thead",
1694
+ "title",
1695
+ "video",
1696
+ "xmp"
1697
+ ]);
1698
+ let Dt = null;
1699
+ const Xe = C({}, ["audio", "video", "img", "source", "image", "track"]);
1700
+ let Et = null;
1701
+ const Mt = C({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Re = "http://www.w3.org/1998/Math/MathML", lt = "http://www.w3.org/2000/svg", ee = "http://www.w3.org/1999/xhtml";
1702
+ let be = ee, ut = !1, dt = null;
1703
+ const Xt = C({}, [Re, lt, ee], sn), xt = se(["mi", "mo", "mn", "ms", "mtext"]);
1704
+ let At = C({}, xt);
1705
+ const Pt = se(["annotation-xml"]);
1706
+ let St = C({}, Pt);
1707
+ const Zt = C({}, ["title", "style", "font", "a", "script"]);
1708
+ let Ze = null;
1709
+ const Jt = ["application/xhtml+xml", "text/html"], Ut = "text/html";
1710
+ let j = null, c = null;
1711
+ const y = r.createElement("form"), I = function(t) {
1712
+ return t instanceof RegExp || t instanceof Function;
1713
+ }, ce = function() {
1714
+ let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1715
+ if (c && c === t)
1716
+ return;
1717
+ (!t || typeof t != "object") && (t = {}), t = ue(t), Ze = // eslint-disable-next-line unicorn/prefer-includes
1718
+ Jt.indexOf(t.PARSER_MEDIA_TYPE) === -1 ? Ut : t.PARSER_MEDIA_TYPE, j = Ze === "application/xhtml+xml" ? sn : Ct, P = Ge(t, "ALLOWED_TAGS", tt, {
1719
+ transform: j
1720
+ }), Y = Ge(t, "ALLOWED_ATTR", nt, {
1721
+ transform: j
1722
+ }), dt = Ge(t, "ALLOWED_NAMESPACES", Xt, {
1723
+ transform: sn
1724
+ }), Et = Ge(t, "ADD_URI_SAFE_ATTR", Mt, {
1725
+ transform: j,
1726
+ base: Mt
1727
+ }), Dt = Ge(t, "ADD_DATA_URI_TAGS", Xe, {
1728
+ transform: j,
1729
+ base: Xe
1730
+ }), ge = Ge(t, "FORBID_CONTENTS", qe, {
1731
+ transform: j
1732
+ }), Ne = Ge(t, "FORBID_TAGS", ue({}), {
1733
+ transform: j
1734
+ }), bt = Ge(t, "FORBID_ATTR", ue({}), {
1735
+ transform: j
1736
+ }), He = ne(t, "USE_PROFILES") ? t.USE_PROFILES && typeof t.USE_PROFILES == "object" ? ue(t.USE_PROFILES) : t.USE_PROFILES : !1, Lt = t.ALLOW_ARIA_ATTR !== !1, $e = t.ALLOW_DATA_ATTR !== !1, rt = t.ALLOW_UNKNOWN_PROTOCOLS || !1, Ue = t.ALLOW_SELF_CLOSE_IN_ATTR !== !1, Ae = t.SAFE_FOR_TEMPLATES || !1, Ye = t.SAFE_FOR_XML !== !1, ke = t.WHOLE_DOCUMENT || !1, De = t.RETURN_DOM || !1, Ke = t.RETURN_DOM_FRAGMENT || !1, st = t.RETURN_TRUSTED_TYPE || !1, at = t.FORCE_BODY || !1, yt = t.SANITIZE_DOM !== !1, Ve = t.SANITIZE_NAMED_PROPS || !1, Tt = t.KEEP_CONTENT !== !1, ct = t.IN_PLACE || !1, Pe = Vo(t.ALLOWED_URI_REGEXP) ? t.ALLOWED_URI_REGEXP : Xn, be = typeof t.NAMESPACE == "string" ? t.NAMESPACE : ee, At = ne(t, "MATHML_TEXT_INTEGRATION_POINTS") && t.MATHML_TEXT_INTEGRATION_POINTS && typeof t.MATHML_TEXT_INTEGRATION_POINTS == "object" ? ue(t.MATHML_TEXT_INTEGRATION_POINTS) : C({}, xt), St = ne(t, "HTML_INTEGRATION_POINTS") && t.HTML_INTEGRATION_POINTS && typeof t.HTML_INTEGRATION_POINTS == "object" ? ue(t.HTML_INTEGRATION_POINTS) : C({}, Pt);
1737
+ const o = ne(t, "CUSTOM_ELEMENT_HANDLING") && t.CUSTOM_ELEMENT_HANDLING && typeof t.CUSTOM_ELEMENT_HANDLING == "object" ? ue(t.CUSTOM_ELEMENT_HANDLING) : mt(null);
1738
+ if ($ = mt(null), ne(o, "tagNameCheck") && I(o.tagNameCheck) && ($.tagNameCheck = o.tagNameCheck), ne(o, "attributeNameCheck") && I(o.attributeNameCheck) && ($.attributeNameCheck = o.attributeNameCheck), ne(o, "allowCustomizedBuiltInElements") && typeof o.allowCustomizedBuiltInElements == "boolean" && ($.allowCustomizedBuiltInElements = o.allowCustomizedBuiltInElements), ie($), Ae && ($e = !1), Ke && (De = !0), He && (P = C({}, Kn), Y = mt(null), He.html === !0 && (C(P, jn), C(Y, Vn)), He.svg === !0 && (C(P, cn), C(Y, dn), C(Y, $t)), He.svgFilters === !0 && (C(P, ln), C(Y, dn), C(Y, $t)), He.mathMl === !0 && (C(P, un), C(Y, qn), C(Y, $t))), Ee.tagCheck = null, Ee.attributeCheck = null, ne(t, "ADD_TAGS") && (typeof t.ADD_TAGS == "function" ? Ee.tagCheck = t.ADD_TAGS : Be(t.ADD_TAGS) && (P === tt && (P = ue(P)), C(P, t.ADD_TAGS, j))), ne(t, "ADD_ATTR") && (typeof t.ADD_ATTR == "function" ? Ee.attributeCheck = t.ADD_ATTR : Be(t.ADD_ATTR) && (Y === nt && (Y = ue(Y)), C(Y, t.ADD_ATTR, j))), ne(t, "ADD_URI_SAFE_ATTR") && Be(t.ADD_URI_SAFE_ATTR) && C(Et, t.ADD_URI_SAFE_ATTR, j), ne(t, "FORBID_CONTENTS") && Be(t.FORBID_CONTENTS) && (ge === qe && (ge = ue(ge)), C(ge, t.FORBID_CONTENTS, j)), ne(t, "ADD_FORBID_CONTENTS") && Be(t.ADD_FORBID_CONTENTS) && (ge === qe && (ge = ue(ge)), C(ge, t.ADD_FORBID_CONTENTS, j)), Tt && (P["#text"] = !0), ke && C(P, ["html", "head", "body"]), P.table && (C(P, ["tbody"]), delete Ne.tbody), t.TRUSTED_TYPES_POLICY) {
1739
+ if (typeof t.TRUSTED_TYPES_POLICY.createHTML != "function")
1740
+ throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1741
+ if (typeof t.TRUSTED_TYPES_POLICY.createScriptURL != "function")
1742
+ throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1743
+ const d = U;
1744
+ U = t.TRUSTED_TYPES_POLICY;
1745
+ try {
1746
+ q = b("");
1747
+ } catch (g) {
1748
+ throw U = d, g;
1749
+ }
1750
+ } else t.TRUSTED_TYPES_POLICY === null ? (U = void 0, q = "") : (U === void 0 && (U = B()), U && typeof q == "string" && (q = b("")));
1751
+ se && se(t), c = t;
1752
+ }, ye = C({}, [...cn, ...ln, ...qo]), fe = C({}, [...un, ...Xo]), Ft = function(t, o, d) {
1753
+ return o.namespaceURI === ee ? t === "svg" : o.namespaceURI === Re ? t === "svg" && (d === "annotation-xml" || At[d]) : !!ye[t];
1754
+ }, Sn = function(t, o, d) {
1755
+ return o.namespaceURI === ee ? t === "math" : o.namespaceURI === lt ? t === "math" && St[d] : !!fe[t];
1756
+ }, wn = function(t, o, d) {
1757
+ return o.namespaceURI === lt && !St[d] || o.namespaceURI === Re && !At[d] ? !1 : !fe[t] && (Zt[t] || !ye[t]);
1758
+ }, Ht = function(t) {
1759
+ let o = N(t);
1760
+ (!o || !o.tagName) && (o = {
1761
+ namespaceURI: be,
1762
+ tagName: "template"
1763
+ });
1764
+ const d = Ct(t.tagName), g = Ct(o.tagName);
1765
+ return dt[t.namespaceURI] ? t.namespaceURI === lt ? Ft(d, o, g) : t.namespaceURI === Re ? Sn(d, o, g) : t.namespaceURI === ee ? wn(d, o, g) : !!(Ze === "application/xhtml+xml" && dt[t.namespaceURI]) : !1;
1766
+ }, ze = function(t) {
1767
+ pt(n.removed, {
1768
+ element: t
1769
+ });
1770
+ try {
1771
+ N(t).removeChild(t);
1772
+ } catch {
1773
+ if (k(t), !N(t))
1774
+ throw Qe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
1775
+ }
1776
+ }, Nn = function(t) {
1777
+ const o = w(t);
1778
+ if (o) {
1779
+ const g = [];
1780
+ Nt(o, (R) => {
1781
+ pt(g, R);
1782
+ }), Nt(g, (R) => {
1783
+ try {
1784
+ k(R);
1785
+ } catch {
1786
+ }
1787
+ });
1788
+ }
1789
+ const d = pe(t);
1790
+ if (d)
1791
+ for (let g = d.length - 1; g >= 0; --g) {
1792
+ const R = d[g], v = R && R.name;
1793
+ if (typeof v == "string")
1794
+ try {
1795
+ t.removeAttribute(v);
1796
+ } catch {
1797
+ }
1798
+ }
1799
+ }, Je = function(t, o) {
1800
+ try {
1801
+ pt(n.removed, {
1802
+ attribute: o.getAttributeNode(t),
1803
+ from: o
1804
+ });
1805
+ } catch {
1806
+ pt(n.removed, {
1807
+ attribute: null,
1808
+ from: o
1809
+ });
1810
+ }
1811
+ if (o.removeAttribute(t), t === "is")
1812
+ if (De || Ke)
1813
+ try {
1814
+ ze(o);
1815
+ } catch {
1816
+ }
1817
+ else
1818
+ try {
1819
+ o.setAttribute(t, "");
1820
+ } catch {
1821
+ }
1822
+ }, pr = function(t) {
1823
+ const o = pe(t);
1824
+ if (o)
1825
+ for (let d = o.length - 1; d >= 0; --d) {
1826
+ const g = o[d], R = g && g.name;
1827
+ if (!(typeof R != "string" || Y[j(R)]))
1828
+ try {
1829
+ t.removeAttribute(R);
1830
+ } catch {
1831
+ }
1832
+ }
1833
+ }, mr = function(t) {
1834
+ const o = [t];
1835
+ for (; o.length > 0; ) {
1836
+ const d = o.pop();
1837
+ (z ? z(d) : d.nodeType) === Ie.element && pr(d);
1838
+ const R = w(d);
1839
+ if (R)
1840
+ for (let v = R.length - 1; v >= 0; --v)
1841
+ o.push(R[v]);
1842
+ }
1843
+ }, kn = function(t) {
1844
+ let o = null, d = null;
1845
+ if (at)
1846
+ t = "<remove></remove>" + t;
1847
+ else {
1848
+ const v = Bn(t, /^[\r\n\t ]+/);
1849
+ d = v && v[0];
1850
+ }
1851
+ Ze === "application/xhtml+xml" && be === ee && (t = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + t + "</body></html>");
1852
+ const g = U ? b(t) : t;
1853
+ if (be === ee)
1854
+ try {
1855
+ o = new T().parseFromString(g, Ze);
1856
+ } catch {
1857
+ }
1858
+ if (!o || !o.documentElement) {
1859
+ o = D.createDocument(be, "template", null);
1860
+ try {
1861
+ o.documentElement.innerHTML = ut ? q : g;
1862
+ } catch {
1863
+ }
1864
+ }
1865
+ const R = o.body || o.documentElement;
1866
+ return t && d && R.insertBefore(r.createTextNode(d), R.childNodes[0] || null), be === ee ? Le.call(o, ke ? "html" : "body")[0] : ke ? o.documentElement : R;
1867
+ }, Rn = function(t) {
1868
+ return W.call(
1869
+ t.ownerDocument || t,
1870
+ t,
1871
+ // eslint-disable-next-line no-bitwise
1872
+ h.SHOW_ELEMENT | h.SHOW_COMMENT | h.SHOW_TEXT | h.SHOW_PROCESSING_INSTRUCTION | h.SHOW_CDATA_SECTION,
1873
+ null
1874
+ );
1875
+ }, zt = function(t) {
1876
+ return t = kt(t, oe, " "), t = kt(t, _t, " "), t = kt(t, Q, " "), t;
1877
+ }, Qt = function(t) {
1878
+ var o;
1879
+ t.normalize();
1880
+ const d = W.call(
1881
+ t.ownerDocument || t,
1882
+ t,
1883
+ // eslint-disable-next-line no-bitwise
1884
+ h.SHOW_TEXT | h.SHOW_COMMENT | h.SHOW_CDATA_SECTION | h.SHOW_PROCESSING_INSTRUCTION,
1885
+ null
1886
+ );
1887
+ let g = d.nextNode();
1888
+ for (; g; )
1889
+ g.data = zt(g.data), g = d.nextNode();
1890
+ const R = (o = t.querySelectorAll) === null || o === void 0 ? void 0 : o.call(t, "template");
1891
+ R && Nt(R, (v) => {
1892
+ ft(v.content) && Qt(v.content);
1893
+ });
1894
+ }, Gt = function(t) {
1895
+ const o = K ? K(t) : null;
1896
+ return typeof o != "string" || j(o) !== "form" ? !1 : typeof t.nodeName != "string" || typeof t.textContent != "string" || typeof t.removeChild != "function" || // Realm-safe NamedNodeMap detection: equality against the cached
1897
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
1898
+ // makes the direct read diverge from the cached read; a clean form
1899
+ // (same-realm OR foreign-realm) has both reads pointing at the same
1900
+ // canonical NamedNodeMap.
1901
+ t.attributes !== pe(t) || typeof t.removeAttribute != "function" || typeof t.setAttribute != "function" || typeof t.namespaceURI != "string" || typeof t.insertBefore != "function" || typeof t.hasChildNodes != "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
1902
+ // returns the integer 1 for any Element regardless of realm; direct
1903
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
1904
+ // the named child element. Cheap addition — nodeType is read from
1905
+ // an internal slot, no serialization cost — and removes a residual
1906
+ // clobbering surface used by several mXSS / PI / comment branches
1907
+ // in _sanitizeElements that compare currentNode.nodeType directly.
1908
+ t.nodeType !== z(t) || // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
1909
+ // "childNodes" shadows the prototype getter. Direct reads of
1910
+ // form.childNodes from a clobbered form return the named child
1911
+ // instead of the real NodeList, so any walk that reads it directly
1912
+ // skips the form's real children. Compare the direct read to the
1913
+ // cached Node.prototype getter — when the form's named-property
1914
+ // getter intercepts the read, the two values differ and we flag
1915
+ // the form. This catches every clobbering child type (input,
1916
+ // select, etc.) regardless of whether the named child happens to
1917
+ // carry a numeric .length, which a typeof-based probe would miss
1918
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
1919
+ t.childNodes !== w(t);
1920
+ }, ft = function(t) {
1921
+ if (!z || typeof t != "object" || t === null)
1922
+ return !1;
1923
+ try {
1924
+ return z(t) === Ie.documentFragment;
1925
+ } catch {
1926
+ return !1;
1927
+ }
1928
+ }, wt = function(t) {
1929
+ if (!z || typeof t != "object" || t === null)
1930
+ return !1;
1931
+ try {
1932
+ return typeof z(t) == "number";
1933
+ } catch {
1934
+ return !1;
1935
+ }
1936
+ };
1937
+ function Me(f, t, o) {
1938
+ f.length !== 0 && Nt(f, (d) => {
1939
+ d.call(n, t, o, c);
1940
+ });
1941
+ }
1942
+ const hr = function(t, o) {
1943
+ return !!(Ye && t.hasChildNodes() && !wt(t.firstElementChild) && ae(Zn, t.textContent) && ae(Zn, t.innerHTML) || Ye && t.namespaceURI === ee && o === "style" && wt(t.firstElementChild) || t.nodeType === Ie.processingInstruction || Ye && t.nodeType === Ie.comment && ae(sa, t.data));
1944
+ }, _r = function(t, o) {
1945
+ if (!Ne[o] && vn(o) && ($.tagNameCheck instanceof RegExp && ae($.tagNameCheck, o) || $.tagNameCheck instanceof Function && $.tagNameCheck(o)))
1946
+ return !1;
1947
+ if (Tt && !ge[o]) {
1948
+ const d = N(t), g = w(t);
1949
+ if (g && d) {
1950
+ const R = g.length;
1951
+ for (let v = R - 1; v >= 0; --v) {
1952
+ const te = ct ? g[v] : E(g[v], !0);
1953
+ d.insertBefore(te, O(t));
1954
+ }
1955
+ }
1956
+ }
1957
+ return ze(t), !0;
1958
+ }, In = function(t) {
1959
+ if (Me(F.beforeSanitizeElements, t, null), Gt(t))
1960
+ return ze(t), !0;
1961
+ const o = j(K ? K(t) : t.nodeName);
1962
+ if (Me(F.uponSanitizeElement, t, {
1963
+ tagName: o,
1964
+ allowedTags: P
1965
+ }), hr(t, o))
1966
+ return ze(t), !0;
1967
+ if (Ne[o] || !(Ee.tagCheck instanceof Function && Ee.tagCheck(o)) && !P[o])
1968
+ return _r(t, o);
1969
+ if ((z ? z(t) : t.nodeType) === Ie.element && !Ht(t) || (o === "noscript" || o === "noembed" || o === "noframes") && ae(ia, t.innerHTML))
1970
+ return ze(t), !0;
1971
+ if (Ae && t.nodeType === Ie.text) {
1972
+ const g = zt(t.textContent);
1973
+ t.textContent !== g && (pt(n.removed, {
1974
+ element: t.cloneNode()
1975
+ }), t.textContent = g);
1976
+ }
1977
+ return Me(F.afterSanitizeElements, t, null), !1;
1978
+ }, Cn = function(t, o, d) {
1979
+ if (bt[o] || yt && (o === "id" || o === "name") && (d in r || d in y))
1980
+ return !1;
1981
+ const g = Y[o] || Ee.attributeCheck instanceof Function && Ee.attributeCheck(o, t);
1982
+ if (!($e && ae(gt, o))) {
1983
+ if (!(Lt && ae(qt, o))) {
1984
+ if (g) {
1985
+ if (!Et[o]) {
1986
+ if (!ae(Pe, kt(d, et, ""))) {
1987
+ if (!((o === "src" || o === "xlink:href" || o === "href") && t !== "script" && Wn(d, "data:") === 0 && Dt[t])) {
1988
+ if (!(rt && !ae(Ot, kt(d, et, "")))) {
1989
+ if (d)
1990
+ return !1;
1991
+ }
1992
+ }
1993
+ }
1994
+ }
1995
+ } else if (
1996
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1997
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1998
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1999
+ !(vn(t) && ($.tagNameCheck instanceof RegExp && ae($.tagNameCheck, t) || $.tagNameCheck instanceof Function && $.tagNameCheck(t)) && ($.attributeNameCheck instanceof RegExp && ae($.attributeNameCheck, o) || $.attributeNameCheck instanceof Function && $.attributeNameCheck(o, t)) || // Alternative, second condition checks if it's an `is`-attribute, AND
2000
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2001
+ o === "is" && $.allowCustomizedBuiltInElements && ($.tagNameCheck instanceof RegExp && ae($.tagNameCheck, d) || $.tagNameCheck instanceof Function && $.tagNameCheck(d)))
2002
+ ) return !1;
2003
+ }
2004
+ }
2005
+ return !0;
2006
+ }, gr = C({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), vn = function(t) {
2007
+ return !gr[Ct(t)] && ae(We, t);
2008
+ }, br = function(t, o, d, g) {
2009
+ if (U && typeof A == "object" && typeof A.getAttributeType == "function" && !d)
2010
+ switch (A.getAttributeType(t, o)) {
2011
+ case "TrustedHTML":
2012
+ return b(g);
2013
+ case "TrustedScriptURL":
2014
+ return L(g);
2015
+ }
2016
+ return g;
2017
+ }, yr = function(t, o, d, g) {
2018
+ try {
2019
+ d ? t.setAttributeNS(d, o, g) : t.setAttribute(o, g), Gt(t) ? ze(t) : Gn(n.removed);
2020
+ } catch {
2021
+ Je(o, t);
2022
+ }
2023
+ }, On = function(t) {
2024
+ Me(F.beforeSanitizeAttributes, t, null);
2025
+ const o = t.attributes;
2026
+ if (!o || Gt(t))
2027
+ return;
2028
+ const d = {
2029
+ attrName: "",
2030
+ attrValue: "",
2031
+ keepAttr: !0,
2032
+ allowedAttributes: Y,
2033
+ forceKeepAttr: void 0
2034
+ };
2035
+ let g = o.length;
2036
+ const R = j(t.nodeName);
2037
+ for (; g--; ) {
2038
+ const v = o[g], te = v.name, X = v.namespaceURI, Te = v.value, Se = j(te), tn = Te;
2039
+ let le = te === "value" ? tn : Bo(tn);
2040
+ if (d.attrName = Se, d.attrValue = le, d.keepAttr = !0, d.forceKeepAttr = void 0, Me(F.uponSanitizeAttribute, t, d), le = d.attrValue, Ve && (Se === "id" || Se === "name") && Wn(le, it) !== 0 && (Je(te, t), le = it + le), Ye && ae(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, le)) {
2041
+ Je(te, t);
2042
+ continue;
2043
+ }
2044
+ if (Se === "attributename" && Bn(le, "href")) {
2045
+ Je(te, t);
2046
+ continue;
2047
+ }
2048
+ if (!d.forceKeepAttr) {
2049
+ if (!d.keepAttr) {
2050
+ Je(te, t);
2051
+ continue;
2052
+ }
2053
+ if (!Ue && ae(ca, le)) {
2054
+ Je(te, t);
2055
+ continue;
2056
+ }
2057
+ if (Ae && (le = zt(le)), !Cn(R, Se, le)) {
2058
+ Je(te, t);
2059
+ continue;
2060
+ }
2061
+ le = br(R, Se, X, le), le !== tn && yr(t, te, X, le);
2062
+ }
2063
+ }
2064
+ Me(F.afterSanitizeAttributes, t, null);
2065
+ }, Bt = function(t) {
2066
+ let o = null;
2067
+ const d = Rn(t);
2068
+ for (Me(F.beforeSanitizeShadowDOM, t, null); o = d.nextNode(); )
2069
+ if (Me(F.uponSanitizeShadowNode, o, null), In(o), On(o), ft(o.content) && Bt(o.content), (z ? z(o) : o.nodeType) === Ie.element) {
2070
+ const R = H(o);
2071
+ ft(R) && (en(R), Bt(R));
2072
+ }
2073
+ Me(F.afterSanitizeShadowDOM, t, null);
2074
+ }, en = function(t) {
2075
+ const o = [{
2076
+ node: t,
2077
+ shadow: null
2078
+ }];
2079
+ for (; o.length > 0; ) {
2080
+ const d = o.pop();
2081
+ if (d.shadow) {
2082
+ Bt(d.shadow);
2083
+ continue;
2084
+ }
2085
+ const g = d.node, v = (z ? z(g) : g.nodeType) === Ie.element, te = w(g);
2086
+ if (te)
2087
+ for (let X = te.length - 1; X >= 0; --X)
2088
+ o.push({
2089
+ node: te[X],
2090
+ shadow: null
2091
+ });
2092
+ if (v) {
2093
+ const X = K ? K(g) : null;
2094
+ if (typeof X == "string" && j(X) === "template") {
2095
+ const Te = g.content;
2096
+ ft(Te) && o.push({
2097
+ node: Te,
2098
+ shadow: null
2099
+ });
2100
+ }
2101
+ }
2102
+ if (v) {
2103
+ const X = H(g);
2104
+ ft(X) && o.push({
2105
+ node: null,
2106
+ shadow: X
2107
+ }, {
2108
+ node: X,
2109
+ shadow: null
2110
+ });
2111
+ }
2112
+ }
2113
+ };
2114
+ return n.sanitize = function(f) {
2115
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = null, d = null, g = null, R = null;
2116
+ if (ut = !f, ut && (f = "<!-->"), typeof f != "string" && !wt(f) && (f = Ko(f), typeof f != "string"))
2117
+ throw Qe("dirty is not a string, aborting");
2118
+ if (!n.isSupported)
2119
+ return f;
2120
+ ot ? (P = je, Y = Fe) : ce(t), (F.uponSanitizeElement.length > 0 || F.uponSanitizeAttribute.length > 0) && (P = ue(P)), F.uponSanitizeAttribute.length > 0 && (Y = ue(Y)), n.removed = [];
2121
+ const v = ct && typeof f != "string" && wt(f);
2122
+ if (v) {
2123
+ const Te = K ? K(f) : f.nodeName;
2124
+ if (typeof Te == "string") {
2125
+ const Se = j(Te);
2126
+ if (!P[Se] || Ne[Se])
2127
+ throw Qe("root node is forbidden and cannot be sanitized in-place");
2128
+ }
2129
+ if (Gt(f))
2130
+ throw Qe("root node is clobbered and cannot be sanitized in-place");
2131
+ try {
2132
+ en(f);
2133
+ } catch (Se) {
2134
+ throw Nn(f), Se;
2135
+ }
2136
+ } else if (wt(f))
2137
+ o = kn("<!---->"), d = o.ownerDocument.importNode(f, !0), d.nodeType === Ie.element && d.nodeName === "BODY" || d.nodeName === "HTML" ? o = d : o.appendChild(d), en(d);
2138
+ else {
2139
+ if (!De && !Ae && !ke && // eslint-disable-next-line unicorn/prefer-includes
2140
+ f.indexOf("<") === -1)
2141
+ return U && st ? b(f) : f;
2142
+ if (o = kn(f), !o)
2143
+ return De ? null : st ? q : "";
2144
+ }
2145
+ o && at && ze(o.firstChild);
2146
+ const te = Rn(v ? f : o);
2147
+ try {
2148
+ for (; g = te.nextNode(); )
2149
+ In(g), On(g), ft(g.content) && Bt(g.content);
2150
+ } catch (Te) {
2151
+ throw v && Nn(f), Te;
2152
+ }
2153
+ if (v)
2154
+ return Nt(n.removed, (Te) => {
2155
+ Te.element && mr(Te.element);
2156
+ }), Ae && Qt(f), f;
2157
+ if (De) {
2158
+ if (Ae && Qt(o), Ke)
2159
+ for (R = he.call(o.ownerDocument); o.firstChild; )
2160
+ R.appendChild(o.firstChild);
2161
+ else
2162
+ R = o;
2163
+ return (Y.shadowroot || Y.shadowrootmode) && (R = xe.call(a, R, !0)), R;
2164
+ }
2165
+ let X = ke ? o.outerHTML : o.innerHTML;
2166
+ return ke && P["!doctype"] && o.ownerDocument && o.ownerDocument.doctype && o.ownerDocument.doctype.name && ae(oa, o.ownerDocument.doctype.name) && (X = "<!DOCTYPE " + o.ownerDocument.doctype.name + `>
2167
+ ` + X), Ae && (X = zt(X)), U && st ? b(X) : X;
2168
+ }, n.setConfig = function() {
2169
+ let f = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2170
+ ce(f), ot = !0, je = P, Fe = Y;
2171
+ }, n.clearConfig = function() {
2172
+ c = null, ot = !1, je = null, Fe = null, U = me, q = "";
2173
+ }, n.isValidAttribute = function(f, t, o) {
2174
+ c || ce({});
2175
+ const d = j(f), g = j(t);
2176
+ return Cn(d, g, o);
2177
+ }, n.addHook = function(f, t) {
2178
+ typeof t == "function" && ne(F, f) && pt(F[f], t);
2179
+ }, n.removeHook = function(f, t) {
2180
+ if (ne(F, f)) {
2181
+ if (t !== void 0) {
2182
+ const o = zo(F[f], t);
2183
+ return o === -1 ? void 0 : Go(F[f], o, 1)[0];
2184
+ }
2185
+ return Gn(F[f]);
2186
+ }
2187
+ }, n.removeHooks = function(f) {
2188
+ ne(F, f) && (F[f] = []);
2189
+ }, n.removeAllHooks = function() {
2190
+ F = Jn();
2191
+ }, n;
2192
+ }
2193
+ var Yt = lr();
2194
+ const da = [
2195
+ "a",
2196
+ "b",
2197
+ "br",
2198
+ "div",
2199
+ "em",
2200
+ "i",
2201
+ "li",
2202
+ "ol",
2203
+ "p",
2204
+ "s",
2205
+ "span",
2206
+ "strong",
2207
+ "u",
2208
+ "ul"
2209
+ ];
2210
+ function fa(e) {
2211
+ e.hasAttribute("href") && (e.setAttribute("target", "_blank"), e.setAttribute("rel", "noopener noreferrer"));
2212
+ }
2213
+ function pa(e) {
2214
+ Yt.addHook("afterSanitizeAttributes", fa);
2215
+ const n = Yt.sanitize(e, {
2216
+ ALLOWED_TAGS: [...da]
2217
+ });
2218
+ return Yt.removeHook("afterSanitizeAttributes"), n;
2219
+ }
2220
+ function ma(e) {
2221
+ return Yt.sanitize(e, { ALLOWED_TAGS: [] });
2222
+ }
2223
+ class En extends Error {
2224
+ constructor(n, r) {
2225
+ super(`HTTP ${n}: ${r}`), this.name = "HttpError", this.status = n, this.statusText = r;
2226
+ }
2227
+ }
2228
+ async function ur(e, n, r, a = {}) {
2229
+ const { authorizationToken: l, headers: s, ...u } = a, m = await fetch(n, {
2230
+ method: e,
2231
+ headers: {
2232
+ "Content-Type": "application/json",
2233
+ ...l && { Authorization: `Bearer ${l}` },
2234
+ ...s
2235
+ },
2236
+ body: r !== void 0 ? JSON.stringify(r) : void 0,
2237
+ ...u
2238
+ });
2239
+ if (!m.ok)
2240
+ throw new En(m.status, m.statusText);
2241
+ return m.json();
2242
+ }
2243
+ const dr = (e, n, r, a) => ur("GET", e, void 0, { signal: r, authorizationToken: a }), An = (e, n, r = {}) => ur("POST", e, n, r);
2244
+ function gn(e) {
2245
+ if (e === "") return "";
2246
+ try {
2247
+ const n = JSON.parse(e);
2248
+ return typeof n == "string" ? n : String(n ?? "");
2249
+ } catch {
2250
+ return e;
2251
+ }
2252
+ }
2253
+ function ha(e) {
2254
+ return e.includes("/chat/agent-completions");
2255
+ }
2256
+ function fr(e) {
2257
+ return /\/conversations(?:\/|$)/.test(e.replace(/\?.*$/, ""));
2258
+ }
2259
+ const It = {
2260
+ model: "gpt-4o-mini",
2261
+ agentName: "Group_Ask_Arbor_Agent",
2262
+ systemPrompt: "You are a helpful AI assistant for Arbor Education group MIS users.",
2263
+ modelKwargs: {
2264
+ temperature: 1,
2265
+ top_p: 1
2266
+ },
2267
+ mcps: [
2268
+ { server: "statsapi", tools: ["*"] },
2269
+ { server: "arbormis", tools: ["create_pdf", "academic_date_range_finder"] }
2270
+ ]
2271
+ }, bn = "user", _a = "assistant", ga = "system";
2272
+ function ba({
2273
+ chatId: e,
2274
+ userMessage: n,
2275
+ chatHistory: r = [],
2276
+ config: a = {}
2277
+ }) {
2278
+ const l = a.model ?? It.model, s = a.agentName ?? It.agentName, u = a.systemPrompt ?? It.systemPrompt, m = a.modelKwargs ?? It.modelKwargs, h = a.mcps ?? [...It.mcps], p = !e && r.length === 0, A = {
2279
+ messages: p ? [
2280
+ { role: ga, content: u },
2281
+ { role: bn, content: n }
2282
+ ] : [{ role: bn, content: n }],
2283
+ model: l,
2284
+ model_kwargs: m,
2285
+ mcps: h,
2286
+ meta: {
2287
+ feature_id: s,
2288
+ source: "ask-arbor-standalone"
2289
+ },
2290
+ moderation_enabled: !0
2291
+ };
2292
+ return e && (A.chat_id = e), p && (A.auto_title = !1), A;
2293
+ }
2294
+ function ya(e) {
2295
+ const n = e.trim();
2296
+ if (!n.startsWith("data:")) return null;
2297
+ const r = n.slice(5).trim();
2298
+ if (!r) return null;
2299
+ try {
2300
+ return JSON.parse(r);
2301
+ } catch {
2302
+ return null;
2303
+ }
2304
+ }
2305
+ async function Ta(e) {
2306
+ var p, T, A;
2307
+ if ((e.headers.get("content-type") ?? "").includes("application/json")) {
2308
+ const E = (p = (await e.json()).items) == null ? void 0 : p[0];
2309
+ return E ? {
2310
+ text: E.text ?? E.content ?? "",
2311
+ chatId: E.chatId,
2312
+ messageId: E.id
2313
+ } : null;
2314
+ }
2315
+ const r = (T = e.body) == null ? void 0 : T.getReader();
2316
+ if (!r) return null;
2317
+ const a = new TextDecoder();
2318
+ let l = "", s = "", u, m = `agent-${Date.now()}`, h = !1;
2319
+ for (; ; ) {
2320
+ const { done: _, value: E } = await r.read();
2321
+ if (_) break;
2322
+ l += a.decode(E, { stream: !0 });
2323
+ const k = l.split(`
2324
+ `);
2325
+ l = k.pop() ?? "";
2326
+ for (const O of k) {
2327
+ const w = O.trim();
2328
+ if (w === "event: error") {
2329
+ h = !0;
2330
+ continue;
2331
+ }
2332
+ const N = ya(w);
2333
+ if (!N) continue;
2334
+ if (N.error || h)
2335
+ throw new Error(
2336
+ N.message_text ?? (typeof N.message == "string" ? N.message : "Agent completion stream failed")
2337
+ );
2338
+ h = !1, N.chat_id && (u = N.chat_id), N.event_id && (m = N.event_id), N.client_message_id && (m = N.client_message_id);
2339
+ const H = (A = N.message) == null ? void 0 : A.content;
2340
+ H && (s = N.is_final ? H : s + H);
2341
+ }
2342
+ }
2343
+ return s ? { text: s, chatId: u, messageId: m } : null;
2344
+ }
2345
+ async function Ea({
2346
+ chatUrl: e,
2347
+ chatId: n,
2348
+ userMessage: r,
2349
+ chatHistory: a,
2350
+ authorizationToken: l,
2351
+ config: s
2352
+ }) {
2353
+ const u = ba({
2354
+ chatId: n,
2355
+ userMessage: r,
2356
+ chatHistory: a,
2357
+ config: s
2358
+ }), m = await fetch(e, {
2359
+ method: "POST",
2360
+ headers: {
2361
+ "Content-Type": "application/json",
2362
+ Accept: "application/json",
2363
+ ...l && { Authorization: `Bearer ${l}` },
2364
+ "X-Trace-Id": crypto.randomUUID()
2365
+ },
2366
+ body: JSON.stringify(u)
2367
+ });
2368
+ if (!m.ok)
2369
+ throw new En(m.status, m.statusText);
2370
+ return Ta(m);
2371
+ }
2372
+ function Aa(e) {
2373
+ switch (e) {
2374
+ case 401:
2375
+ return {
2376
+ text: lo,
2377
+ type: ve
2378
+ };
2379
+ case 403:
2380
+ return {
2381
+ text: uo,
2382
+ type: ve
2383
+ };
2384
+ case 404:
2385
+ return {
2386
+ text: fo,
2387
+ type: ve
2388
+ };
2389
+ case 408:
2390
+ case 504:
2391
+ return {
2392
+ text: po,
2393
+ type: Kt
2394
+ };
2395
+ case 429:
2396
+ return {
2397
+ text: mo,
2398
+ type: Kt
2399
+ };
2400
+ default:
2401
+ return e >= 500 ? {
2402
+ text: ho,
2403
+ type: ve
2404
+ } : {
2405
+ text: ar,
2406
+ type: ve
2407
+ };
2408
+ }
2409
+ }
2410
+ function Sa(e) {
2411
+ return e instanceof En ? Aa(e.status) : e instanceof TypeError ? {
2412
+ text: _o,
2413
+ type: ve
2414
+ } : {
2415
+ text: ar,
2416
+ type: ve
2417
+ };
2418
+ }
2419
+ const wa = 55e3, yn = "fallback", Na = async ({
2420
+ chatId: e = void 0,
2421
+ chatUrl: n,
2422
+ userMessage: r,
2423
+ userInputDeviceLastUsed: a,
2424
+ chatHistory: l,
2425
+ canvasHistory: s,
2426
+ authorizationToken: u,
2427
+ agentCompletionsConfig: m
2428
+ }) => {
2429
+ let h;
2430
+ try {
2431
+ if (ha(n)) {
2432
+ const w = await Ea({
2433
+ chatUrl: n,
2434
+ chatId: e,
2435
+ userMessage: r,
2436
+ chatHistory: l,
2437
+ authorizationToken: u,
2438
+ config: m
2439
+ });
2440
+ return w ? {
2441
+ text: w.text,
2442
+ id: w.messageId,
2443
+ ...w.chatId != null && { chatId: w.chatId },
2444
+ type: jt
2445
+ } : null;
2446
+ }
2447
+ const _ = {
2448
+ chatId: e,
2449
+ userMessage: r,
2450
+ userInputDeviceLastUsed: a,
2451
+ chatHistory: l,
2452
+ canvasHistory: s
2453
+ }, E = new AbortController(), k = An(
2454
+ n,
2455
+ _,
2456
+ { authorizationToken: u, signal: E.signal }
2457
+ ), O = new Promise(
2458
+ (w) => setTimeout(() => {
2459
+ E.abort(), w({
2460
+ items: [
2461
+ {
2462
+ id: yn,
2463
+ hardStopped: !0,
2464
+ type: mn
2465
+ }
2466
+ ]
2467
+ });
2468
+ }, wa)
2469
+ );
2470
+ h = await Promise.race([k, O]);
2471
+ } catch (_) {
2472
+ console.error("Error in getNewAgentMessage", _);
2473
+ const { text: E, type: k } = Sa(_);
2474
+ return {
2475
+ text: E,
2476
+ type: k,
2477
+ id: crypto.randomUUID()
2478
+ };
2479
+ }
2480
+ const p = h.items[0];
2481
+ if (!p) return null;
2482
+ const T = p.text != null && p.text !== "" ? p.text : gn(
2483
+ typeof p.content == "string" ? p.content : ""
2484
+ );
2485
+ return {
2486
+ text: typeof T == "string" ? T : "",
2487
+ id: p.id,
2488
+ ...p.chatId != null && { chatId: p.chatId },
2489
+ ...p.timedOut != null && { timedOut: p.timedOut },
2490
+ ...p.deferred != null && { deferred: p.deferred },
2491
+ ...p.hardStopped != null && { hardStopped: p.hardStopped },
2492
+ type: p.type,
2493
+ ...p.element != null && { element: p.element }
2494
+ };
2495
+ }, ka = (e) => new Date(e).toLocaleDateString("en-GB", {
2496
+ day: "numeric",
2497
+ month: "short",
2498
+ year: "numeric"
2499
+ }), Ra = [
2500
+ {
2501
+ field: "title",
2502
+ headerName: "Conversation",
2503
+ flex: 1
2504
+ },
2505
+ {
2506
+ field: "updatedAt",
2507
+ headerName: "Last Conversation",
2508
+ width: 140,
2509
+ valueFormatter: ({ value: e }) => ka(e)
2510
+ }
2511
+ ], Ia = {
2512
+ sortable: !1,
2513
+ filter: !1,
2514
+ resizable: !1,
2515
+ editable: !1,
2516
+ suppressHeaderMenuButton: !0
2517
+ }, fn = "NONE", Ca = "KEYBOARD", va = "VOICE", Oa = "MIXED", La = 2e4, Da = 15, Ma = (e, n) => new Promise((r) => {
2518
+ if (n != null && n.aborted) {
2519
+ r(!1);
2520
+ return;
2521
+ }
2522
+ const a = setTimeout(() => {
2523
+ n == null || n.removeEventListener("abort", l), r(!0);
2524
+ }, e), l = () => {
2525
+ clearTimeout(a), r(!1);
2526
+ };
2527
+ n == null || n.addEventListener("abort", l);
2528
+ }), ja = ({
2529
+ title: e,
2530
+ connector: n,
2531
+ newChatUrl: r,
2532
+ lockConversation: a = !1,
2533
+ messageLimit: l,
2534
+ chatId: s,
2535
+ speechEnabled: u = !0,
2536
+ speechLanguage: m = "en-GB",
2537
+ speechSubmissionDelay: h = 1e3,
2538
+ chatHistory: p,
2539
+ canvasHistory: T,
2540
+ refreshAgentMessages: A,
2541
+ startQuery: _,
2542
+ slashMenuItems: E,
2543
+ menuContent: k,
2544
+ samplePrompts: O,
2545
+ dailyPrompt: w,
2546
+ prompts: N,
2547
+ promptLibrary: H,
2548
+ placeholder: pe = "Explain what you need in your own words...",
2549
+ introHeading: z = "Get instant answers from your MIS",
2550
+ introBody: K = "Type a question about your students, staff or school and get the answer in seconds. No reports to run, no clicking around - just ask!",
2551
+ onClose: U,
2552
+ onNavigate: q,
2553
+ onRatingPopupOpen: me,
2554
+ focusDelay: J
2555
+ }) => {
2556
+ const G = (() => {
2557
+ if (H && H.length > 0) return H;
2558
+ if (!N || N.trim() === "") return [];
2559
+ try {
2560
+ const c = JSON.parse(N);
2561
+ return Array.isArray(c) && c.length > 0 ? c : [];
2562
+ } catch {
2563
+ return [];
2564
+ }
2565
+ })(), de = x(!1), b = (c) => {
2566
+ de.current = c;
2567
+ }, L = Ro(), B = x(null), re = x(null), D = x(null), W = x(null), he = x(null), Le = x(null), [xe, F] = M(
2568
+ () => s ? "" : _ ?? ""
2569
+ ), [oe, _t] = M(s), [Q, gt] = M([]), [qt, Ot] = M([]), et = (c) => {
2570
+ (!de.current || c.id === "DEEP_THINKING_MESSAGE") && gt((y) => [...y, c]);
2571
+ }, [We, Pe] = M(!1), [P, tt] = M(!1), [Y, nt] = M(!1), $ = x(!1), Ne = x(null), bt = x(!1), [Ee, Lt] = M(!1), [$e, rt] = M(fn), [Ue, Ae] = M(!1), [Ye, ke] = M(!0), [ot, je] = M(!1), [Fe, at] = M("getting-started"), [De, Ke] = M([]), [st, yt] = M(!1), Ve = Co(l, 0), it = Ve > 0 && Q.length >= Ve, Tt = We || P;
2572
+ ko(() => {
2573
+ if (!!(_ != null && _.trim()) && !s || J == null && !_) return;
2574
+ const y = setTimeout(() => {
2575
+ var I;
2576
+ (I = B.current) == null || I.focus();
2577
+ }, J ?? 0);
2578
+ return () => clearTimeout(y);
2579
+ });
2580
+ const [ct, He] = M(!1), ge = !window.webkitSpeechRecognition && !window.SpeechRecognition, qe = typeof navigator < "u" && navigator.userAgent.toLowerCase().includes("firefox"), Dt = async () => {
2581
+ let c = !1;
2582
+ if (navigator.permissions)
2583
+ try {
2584
+ c = (await navigator.permissions.query({
2585
+ name: "microphone"
2586
+ })).state === "denied";
2587
+ } catch (y) {
2588
+ console.warn("Could not check microphone permission:", y);
2589
+ }
2590
+ return !u || ge || qe || c;
2591
+ };
2592
+ V(() => {
2593
+ (async () => {
2594
+ const y = await Dt();
2595
+ He(y);
2596
+ })();
2597
+ }, [u, Ue]), V(() => {
2598
+ p && p.length > 0 && gt(p);
2599
+ }, [p]);
2600
+ const Xe = async (c = oe) => {
2601
+ if (!n.canLoadHistory || !c) return;
2602
+ tt(!0);
2603
+ const y = await n.loadHistory(c);
2604
+ if (L.current) {
2605
+ if (JSON.stringify(y) === JSON.stringify(Q) || !y) {
2606
+ tt(!1);
2607
+ return;
2608
+ }
2609
+ return y.chatItems.length > 0 && gt(y.chatItems), Ot(y.followUpPrompts), tt(!1), Lt(!0), y;
2610
+ }
2611
+ };
2612
+ V(() => {
2613
+ A && !de.current && Xe();
2614
+ }, [A]), V(() => {
2615
+ L.current && n.canLoadHistory && s && (Ee || Xe(s));
2616
+ }, [s, n.canLoadHistory, Ee]), er(() => {
2617
+ D.current && D.current.scrollTo({
2618
+ top: D.current.scrollHeight,
2619
+ behavior: "smooth"
2620
+ });
2621
+ }, [Q]);
2622
+ const Et = (c) => {
2623
+ const y = Oo(c), I = /\['Canvas_Element_ID'\s*:\s*'([^']+)',\s*'Title'\s*:\s*'([^']+)'\]/g;
2624
+ return y.replace(
2625
+ I,
2626
+ (ce, ye, fe) => `<span class="chat-panel__message-tag">@${fe}</span>`
2627
+ );
2628
+ }, Mt = async ({
2629
+ maxAttempts: c = 6,
2630
+ chatIdToFetch: y,
2631
+ signal: I
2632
+ } = {}) => {
2633
+ const ce = new Set(Q.map(({ id: Ft }) => Ft));
2634
+ let ye = 0, fe;
2635
+ for (; ye < c; ) {
2636
+ if (I != null && I.aborted || !await Ma(La, I) || (fe = await Xe(y), I != null && I.aborted)) return;
2637
+ if (((fe == null ? void 0 : fe.chatItems) || []).some(
2638
+ (Ht) => Ht.type !== ht && !ce.has(Ht.id)
2639
+ )) break;
2640
+ ye++;
2641
+ }
2642
+ if (Number.isFinite(c) && ye >= c) {
2643
+ et({
2644
+ text: go,
2645
+ id: yn,
2646
+ type: ve
2647
+ });
2648
+ return;
2649
+ }
2650
+ return fe;
2651
+ }, Re = () => {
2652
+ setTimeout(() => {
2653
+ var c;
2654
+ (c = B.current) == null || c.focus();
2655
+ }, 0);
2656
+ }, lt = async (c) => {
2657
+ Ot(null), Pe(!0);
2658
+ const y = await n.sendMessage({
2659
+ chatId: oe,
2660
+ userMessage: c,
2661
+ userInputDeviceLastUsed: $e,
2662
+ chatHistory: Q,
2663
+ canvasHistory: T
2664
+ });
2665
+ if (!y) {
2666
+ Pe(!1), Re();
2667
+ return;
2668
+ }
2669
+ if (y.deferred === !0) {
2670
+ y.chatId && _t(y.chatId);
2671
+ const I = y.chatId || oe;
2672
+ Ne.current = new AbortController();
2673
+ try {
2674
+ await Mt({
2675
+ maxAttempts: Da,
2676
+ chatIdToFetch: I,
2677
+ signal: Ne.current.signal
2678
+ });
2679
+ } finally {
2680
+ Ne.current = null;
2681
+ }
2682
+ L.current && (Pe(!1), Re());
2683
+ return;
2684
+ }
2685
+ if (y.hardStopped === !0) {
2686
+ !$.current && n.canSendNotification && oe && await n.sendNotification({ chatId: oe }) && ($.current = !0), L.current && (nt(!0), Pe(!1), Re());
2687
+ return;
2688
+ }
2689
+ et({
2690
+ text: pa(y.text),
2691
+ type: y.type,
2692
+ id: y.id,
2693
+ ...y.element != null && { element: y.element }
2694
+ }), y.chatId && _t(y.chatId), Pe(!1), Re();
2695
+ }, ee = async ({
2696
+ prompt: c = null,
2697
+ allowDoubleMessage: y = !1
2698
+ } = {}) => {
2699
+ var ye;
2700
+ let I = null;
2701
+ if (c != null && c.trim() !== "" && (I = c.trim()), I === null && (I = ma(xe).trim()), !I || We || P) return;
2702
+ const ce = Q.slice().reverse().find((fe) => fe.type === ht);
2703
+ if (!y && ce && ce.text === I) {
2704
+ console.warn("Duplicate message detected, not adding:", I);
2705
+ return;
2706
+ }
2707
+ (ye = Le.current) == null || ye.cancel(), be(), nt(!1), $.current = !1, et({
2708
+ type: ht,
2709
+ text: I,
2710
+ id: Io()
2711
+ }), F(""), Re(), b(!1), await lt(I), rt(fn);
2712
+ };
2713
+ V(() => {
2714
+ if (bt.current || !(_ != null && _.trim()) || s) return;
2715
+ bt.current = !0;
2716
+ const c = setTimeout(() => {
2717
+ ee({ prompt: _ });
2718
+ }, J ?? 0);
2719
+ return () => clearTimeout(c);
2720
+ }, []);
2721
+ const be = () => {
2722
+ he.current && (he.current.stop(), he.current = null), Ae(!1), W.current && (clearTimeout(W.current), W.current = null);
2723
+ }, ut = Ir((c) => {
2724
+ be(), c.trim().length > 0 && Ye && ee();
2725
+ }, h);
2726
+ Le.current = ut;
2727
+ const dt = (c) => {
2728
+ if ($e === fn) {
2729
+ rt(c);
2730
+ return;
2731
+ }
2732
+ if ($e !== c) {
2733
+ rt(Oa);
2734
+ return;
2735
+ }
2736
+ }, Xt = () => {
2737
+ if (We || P) return;
2738
+ dt(va), ke(!0);
2739
+ const c = new window.webkitSpeechRecognition();
2740
+ he.current = c, c.continuous = !0, c.interimResults = !0, c.lang = m, c.start(), c.onstart = () => {
2741
+ Ae(!0);
2742
+ }, c.onresult = (y) => {
2743
+ const I = Array.from(y.results).map((ce) => ce[0]).map((ce) => ce.transcript).join("");
2744
+ I !== xe && F(I), ut(I);
2745
+ }, c.onerror = () => {
2746
+ be();
2747
+ };
2748
+ }, xt = () => {
2749
+ Ue ? be() : Xt();
2750
+ }, At = !P && !We && xe.trim().length > 0;
2751
+ V(
2752
+ () => () => {
2753
+ var c;
2754
+ (c = Ne.current) == null || c.abort();
2755
+ },
2756
+ []
2757
+ ), V(() => {
2758
+ if (!n.canListInteractions) return;
2759
+ let c = !1;
2760
+ return yt(!0), n.listInteractions().then((y) => {
2761
+ c || Ke(y ?? []);
2762
+ }).catch(() => {
2763
+ c || Ke([]);
2764
+ }).finally(() => {
2765
+ c || yt(!1);
2766
+ }), () => {
2767
+ c = !0;
2768
+ };
2769
+ }, [n]);
2770
+ const Pt = () => E != null && E.length ? E.map((c) => {
2771
+ let y = c.url;
2772
+ return oe && y.includes("/chat-id/") && (y.match(/\/chat-id\/[^/]+$/) || (y = `${y}${oe}`)), {
2773
+ reference: c.label,
2774
+ description: c.label,
2775
+ link: y,
2776
+ icon: c.icon
2777
+ };
2778
+ }) : [], St = (c) => {
2779
+ c.key !== "Enter" && (dt(Ca), Ue && ke(!1), c.key === "/" && xe.length === 0 && (E != null && E.length) && (je(!0), c.preventDefault())), c.key === "Enter" && !c.shiftKey && (c.preventDefault(), At && ee({ allowDoubleMessage: !0 })), c.key === "Escape" && ot && je(!1);
2780
+ }, Zt = () => {
2781
+ je(!1), setTimeout(() => {
2782
+ var c;
2783
+ (c = B.current) == null || c.focus();
2784
+ }, 0);
2785
+ }, Ze = Wt((c) => {
2786
+ F(c), setTimeout(() => {
2787
+ B.current && (B.current.focus(), B.current.selectionStart = B.current.value.length, B.current.selectionEnd = B.current.value.length);
2788
+ }, 0);
2789
+ }, []), Jt = Wt(async () => !n.canSendNotification || !oe ? !1 : n.sendNotification({ chatId: oe }), [oe, n]), Ut = Wt(() => {
2790
+ nt(!1), U == null || U();
2791
+ }, [U]), j = Wt(
2792
+ (c, y) => {
2793
+ oe && n.rateMessage({ rating: c, messageId: y, chatId: oe });
2794
+ },
2795
+ [oe, n]
2796
+ );
2797
+ return /* @__PURE__ */ S("section", { "aria-label": e ? `Chat Panel: ${e}` : "Chat Panel", className: "chat-panel", children: [
2798
+ r && Q.length > 0 && /* @__PURE__ */ i("section", { className: "chat-panel__active-chat-header", children: /* @__PURE__ */ i(
2799
+ "a",
2800
+ {
2801
+ href: r,
2802
+ className: "chat-panel__new-chat-button",
2803
+ onClick: (c) => {
2804
+ q && (c.preventDefault(), q(r));
2805
+ },
2806
+ children: "New"
2807
+ }
2808
+ ) }),
2809
+ (Q.length > 0 || !a && !it) && /* @__PURE__ */ S(
2810
+ "div",
2811
+ {
2812
+ className: _e("chat-panel__body", {
2813
+ "chat-panel__body--no-messages": Q.length === 0
2814
+ }),
2815
+ children: [
2816
+ Q.length > 0 && /* @__PURE__ */ S("div", { className: "chat-panel__message-list-wrapper", children: [
2817
+ /* @__PURE__ */ S("ul", { className: "chat-panel-message-list", ref: D, children: [
2818
+ Q.map((c, y) => {
2819
+ const I = y === Q.length - 1, ce = I ? qt : void 0, ye = c.id === yn, fe = I;
2820
+ return /* @__PURE__ */ i(
2821
+ co,
2822
+ {
2823
+ id: c.id,
2824
+ type: c.type,
2825
+ text: c.text,
2826
+ chatId: oe,
2827
+ onRate: n.canRate ? j : void 0,
2828
+ ratingPopupUrls: n.ratingPopupUrls,
2829
+ showRating: fe,
2830
+ followUpPrompts: ce,
2831
+ onFollowUpPromptClick: Ze,
2832
+ processCanvasReferences: Et,
2833
+ isFallbackMessage: ye,
2834
+ onRatingPopupOpen: me
2835
+ },
2836
+ `${c.id}_${y}`
2837
+ );
2838
+ }),
2839
+ Tt && /* @__PURE__ */ i(
2840
+ No,
2841
+ {
2842
+ showNotifyLaterButton: n.canSendNotification && !!oe,
2843
+ onNotifyLater: Jt,
2844
+ onNotificationRegisteredGotIt: Ut
2845
+ }
2846
+ ),
2847
+ Y && /* @__PURE__ */ i(
2848
+ "li",
2849
+ {
2850
+ className: "chat-panel__hard-stop-banner",
2851
+ "data-testid": "hard-stop-banner",
2852
+ children: /* @__PURE__ */ S("div", { className: "chat-panel__notify-later", children: [
2853
+ /* @__PURE__ */ i("p", { className: "chat-panel__notify-later-message", children: "This one's taking longer than usual. We'll notify you in the notifications panel on the left of your MIS when it's done." }),
2854
+ /* @__PURE__ */ i(
2855
+ "button",
2856
+ {
2857
+ type: "button",
2858
+ className: "chat-panel__notify-later-btn",
2859
+ onClick: Ut,
2860
+ "aria-label": "Got it",
2861
+ children: "Got it"
2862
+ }
2863
+ )
2864
+ ] })
2865
+ }
2866
+ )
2867
+ ] }),
2868
+ Ve > 0 && Q.length > 0 && /* @__PURE__ */ S("div", { className: "chat-panel__message-limit", children: [
2869
+ Q.length,
2870
+ " ",
2871
+ "/",
2872
+ Ve
2873
+ ] })
2874
+ ] }),
2875
+ !a && !it && /* @__PURE__ */ S(we, { children: [
2876
+ Q.length === 0 && !P && /* @__PURE__ */ S("div", { className: "chat-panel__chat-intro", children: [
2877
+ /* @__PURE__ */ S("div", { className: "chat-panel__chat-intro-frame", children: [
2878
+ /* @__PURE__ */ i("span", { className: "chat-panel__chat-intro-icon", children: /* @__PURE__ */ i(Cr, {}) }),
2879
+ /* @__PURE__ */ i("h3", { className: "chat-panel__chat-intro-heading", children: z })
2880
+ ] }),
2881
+ /* @__PURE__ */ i("p", { className: "chat-panel__chat-intro-body", children: K })
2882
+ ] }),
2883
+ /* @__PURE__ */ i("div", { className: "chat-panel__input-container", children: /* @__PURE__ */ S("div", { className: "chat-panel__input-wrapper", ref: re, children: [
2884
+ ot && /* @__PURE__ */ i(
2885
+ sr,
2886
+ {
2887
+ anchorRef: re,
2888
+ menuItems: Pt(),
2889
+ onClose: Zt,
2890
+ onNavigate: q
2891
+ }
2892
+ ),
2893
+ /* @__PURE__ */ i(
2894
+ or,
2895
+ {
2896
+ ref: B,
2897
+ value: xe,
2898
+ onChange: F,
2899
+ onKeyDown: St,
2900
+ placeholder: pe,
2901
+ onSubmit: () => {
2902
+ xe.trim() && ee({
2903
+ allowDoubleMessage: !0
2904
+ });
2905
+ },
2906
+ onMicClick: xt,
2907
+ onStopClick: () => {
2908
+ Ue && be();
2909
+ },
2910
+ isProcessing: We,
2911
+ speechEngaged: Ue,
2912
+ showMicButton: !ct && u && !qe,
2913
+ ariaLabel: "Chat panel input",
2914
+ menuContent: k,
2915
+ onNavigate: q,
2916
+ showDisclaimer: Q.length > 0
2917
+ }
2918
+ )
2919
+ ] }) })
2920
+ ] })
2921
+ ]
2922
+ }
2923
+ ),
2924
+ Q.length === 0 && /* @__PURE__ */ S(we, { children: [
2925
+ ct && /* @__PURE__ */ i("div", { className: "chat-panel__speech-disabled-wrapper", children: qe ? /* @__PURE__ */ S(we, { children: [
2926
+ " ",
2927
+ "Speech isn't supported in Firefox. To enable speech, please use Google Chrome."
2928
+ ] }) : /* @__PURE__ */ i(we, { children: " To use speech, please allow Arbor to use your microphone." }) }),
2929
+ /* @__PURE__ */ S(nn, { className: "chat-panel__tabs", children: [
2930
+ /* @__PURE__ */ i(
2931
+ nn.Item,
2932
+ {
2933
+ active: Fe === "getting-started",
2934
+ tabElementProps: {
2935
+ onClick: () => at("getting-started")
2936
+ },
2937
+ children: "Getting started"
2938
+ }
2939
+ ),
2940
+ /* @__PURE__ */ i(
2941
+ nn.Item,
2942
+ {
2943
+ active: Fe === "recent",
2944
+ tabElementProps: {
2945
+ onClick: () => at("recent")
2946
+ },
2947
+ children: "Recent"
2948
+ }
2949
+ )
2950
+ ] }),
2951
+ /* @__PURE__ */ S("div", { className: "chat-panel__tab-content", children: [
2952
+ Fe === "getting-started" && /* @__PURE__ */ S(we, { children: [
2953
+ G.length > 0 && /* @__PURE__ */ i("div", { className: "chat-panel__sample-prompt-container", children: /* @__PURE__ */ i(
2954
+ Lr,
2955
+ {
2956
+ onSelectPrompt: (c) => {
2957
+ ee({
2958
+ prompt: c,
2959
+ allowDoubleMessage: !0
2960
+ });
2961
+ },
2962
+ onPromptHover: (c) => {
2963
+ c != null && F(c);
2964
+ },
2965
+ categories: G
2966
+ }
2967
+ ) }),
2968
+ (O && O.length > 0 && G.length === 0 || !!(w != null && w.trim())) && /* @__PURE__ */ S("div", { className: "chat-panel__sample-prompt-container", children: [
2969
+ O == null ? void 0 : O.map((c, y) => /* @__PURE__ */ i(
2970
+ "button",
2971
+ {
2972
+ type: "button",
2973
+ className: "chat-panel__sample-prompt",
2974
+ onClick: () => ee({
2975
+ prompt: c,
2976
+ allowDoubleMessage: !0
2977
+ }),
2978
+ children: c
2979
+ },
2980
+ `sample-${y}`
2981
+ )),
2982
+ w && /* @__PURE__ */ i(
2983
+ "button",
2984
+ {
2985
+ type: "button",
2986
+ className: "chat-panel__daily-prompt",
2987
+ onClick: () => ee({
2988
+ prompt: w,
2989
+ allowDoubleMessage: !0
2990
+ }),
2991
+ children: /* @__PURE__ */ S("span", { children: [
2992
+ "✨",
2993
+ " ",
2994
+ /* @__PURE__ */ i("strong", { children: "Daily Prompt:" }),
2995
+ /* @__PURE__ */ i("br", {}),
2996
+ w
2997
+ ] })
2998
+ },
2999
+ "daily-prompt"
3000
+ )
3001
+ ] })
3002
+ ] }),
3003
+ Fe === "recent" && /* @__PURE__ */ i("div", { className: "chat-panel__tab-panel--recent", children: st ? /* @__PURE__ */ i("div", { className: "chat-panel__ai-interactions-loading", children: "Loading..." }) : De.length === 0 ? /* @__PURE__ */ i("div", { className: "chat-panel__ai-interactions-empty", children: "No previous chats found." }) : /* @__PURE__ */ i(
3004
+ Er,
3005
+ {
3006
+ wrapperClassName: "chat-panel__ai-interactions-table",
3007
+ hasSearch: !1,
3008
+ tableTheme: "tidy",
3009
+ domLayout: "autoHeight",
3010
+ rowData: De,
3011
+ columnDefs: Ra,
3012
+ defaultColDef: Ia,
3013
+ getRowId: ({ data: c }) => c.id,
3014
+ onRowClicked: ({ data: c }) => {
3015
+ !c || !n.canLoadHistory || (_t(c.chatId), Xe(c.chatId));
3016
+ }
3017
+ }
3018
+ ) })
3019
+ ] })
3020
+ ] }),
3021
+ it && /* @__PURE__ */ i("div", { className: "chat-panel-footer", children: "You've reached the maximum number of messages for this conversation" })
3022
+ ] });
3023
+ };
3024
+ function xa(e) {
3025
+ switch (e.toLowerCase()) {
3026
+ case bn:
3027
+ return ht;
3028
+ case _a:
3029
+ return jt;
3030
+ default:
3031
+ return null;
3032
+ }
3033
+ }
3034
+ function Pa(e) {
3035
+ const n = [];
3036
+ for (const r of e.messages ?? []) {
3037
+ const a = xa(r.role);
3038
+ !a || !r.content || n.push({
3039
+ id: r.message_id,
3040
+ type: a,
3041
+ text: r.content
3042
+ });
3043
+ }
3044
+ return { chatItems: n, followUpPrompts: [] };
3045
+ }
3046
+ const Ua = async (e, n) => {
3047
+ try {
3048
+ const r = await dr(e, void 0, void 0, n);
3049
+ if (fr(e) && Array.isArray(r == null ? void 0 : r.messages))
3050
+ return Pa(r);
3051
+ if (!(r != null && r.items))
3052
+ return console.error("Invalid response in getHistoricMessages", e, r), { chatItems: [], followUpPrompts: [] };
3053
+ let a = [], l = [];
3054
+ return r.items.forEach((s) => {
3055
+ if ("chatItems" in s)
3056
+ a = s.chatItems.map(
3057
+ ({ id: u, type: m, text: h, content: p, ...T }) => {
3058
+ const A = h != null && h !== "" ? h : gn(
3059
+ typeof p == "string" ? p : ""
3060
+ );
3061
+ return {
3062
+ id: u,
3063
+ type: m.toUpperCase(),
3064
+ text: A,
3065
+ ...T.element != null && { element: T.element }
3066
+ };
3067
+ }
3068
+ );
3069
+ else if ("id" in s && "type" in s) {
3070
+ const u = s.text != null && s.text !== "" ? s.text : gn(
3071
+ typeof s.content == "string" ? s.content : ""
3072
+ );
3073
+ a.push({
3074
+ id: s.id,
3075
+ type: s.type.toUpperCase(),
3076
+ text: u,
3077
+ ...s.element != null && { element: s.element }
3078
+ });
3079
+ }
3080
+ "followUpPrompts" in s && (l = s.followUpPrompts || []);
3081
+ }), { chatItems: a, followUpPrompts: l };
3082
+ } catch (r) {
3083
+ return console.error("Error in getHistoricMessages", r, e), { chatItems: [], followUpPrompts: [] };
3084
+ }
3085
+ }, Fa = async ({
3086
+ rating: e,
3087
+ messageId: n,
3088
+ chatId: r,
3089
+ ratingUrl: a,
3090
+ authorizationToken: l
3091
+ }) => {
3092
+ try {
3093
+ await An(a, { messageId: n, rating: e, chatId: r }, { authorizationToken: l });
3094
+ } catch (s) {
3095
+ console.error("Error rating message", s);
3096
+ }
3097
+ }, Ha = async ({
3098
+ chatId: e,
3099
+ notificationCallbackUrl: n,
3100
+ authorizationToken: r
3101
+ }) => {
3102
+ try {
3103
+ return await An(n, { chatId: e }, { authorizationToken: r }), !0;
3104
+ } catch (a) {
3105
+ return console.error("Error sending notification", a), !1;
3106
+ }
3107
+ };
3108
+ function za(e) {
3109
+ return (e.conversations ?? []).map((n) => {
3110
+ var r, a;
3111
+ return {
3112
+ id: n.session_id,
3113
+ chatId: n.session_id,
3114
+ title: ((r = n.title) == null ? void 0 : r.trim()) || ((a = n.preview) == null ? void 0 : a.trim()) || "Untitled conversation",
3115
+ updatedAt: n.updated_at ?? n.created_at ?? ""
3116
+ };
3117
+ });
3118
+ }
3119
+ class Ga {
3120
+ constructor(n) {
3121
+ this.config = n;
3122
+ }
3123
+ get canRate() {
3124
+ return !!this.config.ratingUrl;
3125
+ }
3126
+ get canLoadHistory() {
3127
+ return !!this.config.historicChatUrl;
3128
+ }
3129
+ get canListInteractions() {
3130
+ return !!this.config.aiInteractionsUrl;
3131
+ }
3132
+ get canSendNotification() {
3133
+ return !!this.config.notificationCallbackUrl;
3134
+ }
3135
+ get ratingPopupUrls() {
3136
+ return {
3137
+ up: this.config.upRatingPopupUrl,
3138
+ down: this.config.downRatingPopupUrl
3139
+ };
3140
+ }
3141
+ async sendMessage(n) {
3142
+ return Na({
3143
+ chatUrl: this.config.chatUrl,
3144
+ authorizationToken: this.config.authorizationToken,
3145
+ agentCompletionsConfig: this.config.agentCompletionsConfig,
3146
+ ...n
3147
+ });
3148
+ }
3149
+ async loadHistory(n) {
3150
+ return this.config.historicChatUrl ? Ua(
3151
+ `${this.config.historicChatUrl}/${n}`,
3152
+ this.config.authorizationToken
3153
+ ) : null;
3154
+ }
3155
+ async listInteractions() {
3156
+ if (!this.config.aiInteractionsUrl) return null;
3157
+ try {
3158
+ const n = await dr(
3159
+ this.config.aiInteractionsUrl,
3160
+ void 0,
3161
+ void 0,
3162
+ this.config.authorizationToken
3163
+ );
3164
+ return fr(this.config.aiInteractionsUrl) && Array.isArray(n.conversations) ? za(
3165
+ n
3166
+ ) : Array.isArray(n) ? n : Array.isArray(n.items) ? n.items : [];
3167
+ } catch {
3168
+ return null;
3169
+ }
3170
+ }
3171
+ async rateMessage(n) {
3172
+ this.config.ratingUrl && await Fa({
3173
+ ratingUrl: this.config.ratingUrl,
3174
+ authorizationToken: this.config.authorizationToken,
3175
+ ...n
3176
+ });
3177
+ }
3178
+ async sendNotification(n) {
3179
+ return this.config.notificationCallbackUrl ? Ha({
3180
+ notificationCallbackUrl: this.config.notificationCallbackUrl,
3181
+ authorizationToken: this.config.authorizationToken,
3182
+ ...n
3183
+ }) : !1;
3184
+ }
3185
+ }
3186
+ const Ka = {
3187
+ create(e) {
3188
+ const n = e.model || e.agentName || e.systemPrompt || e.mcps ? {
3189
+ ...e.model && { model: e.model },
3190
+ ...e.agentName && { agentName: e.agentName },
3191
+ ...e.systemPrompt && { systemPrompt: e.systemPrompt },
3192
+ ...e.mcps && { mcps: e.mcps }
3193
+ } : void 0;
3194
+ return new Ga({
3195
+ chatUrl: e.chatUrl,
3196
+ authorizationToken: e.authorizationToken ?? void 0,
3197
+ historicChatUrl: e.historicChatUrl ?? void 0,
3198
+ aiInteractionsUrl: e.aiInteractionsUrl ?? void 0,
3199
+ ratingUrl: e.ratingUrl ?? void 0,
3200
+ upRatingPopupUrl: e.upRatingPopupUrl ?? void 0,
3201
+ downRatingPopupUrl: e.downRatingPopupUrl ?? void 0,
3202
+ notificationCallbackUrl: e.notificationCallbackUrl ?? void 0,
3203
+ agentCompletionsConfig: n
3204
+ });
3205
+ }
3206
+ };
3207
+ export {
3208
+ Ka as AIServiceConnectorFactory,
3209
+ jt as CHAT_RESPONSE_TYPE_AGENT,
3210
+ ve as CHAT_RESPONSE_TYPE_ERROR,
3211
+ mn as CHAT_RESPONSE_TYPE_INFO,
3212
+ ht as CHAT_RESPONSE_TYPE_USER,
3213
+ Kt as CHAT_RESPONSE_TYPE_WARNING,
3214
+ ja as ChatPanel,
3215
+ Ga as HttpAIServiceConnector
3216
+ };