@iai-lib/any-chat-widget 0.1.0-alpha.11 → 0.1.0-alpha.13
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.
|
@@ -6,7 +6,7 @@ var Zt = (s, e, t) => (ri(s, e, "read from private field"), t ? t.call(s) : e.ge
|
|
|
6
6
|
if (e.has(s))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
8
|
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
9
|
-
},
|
|
9
|
+
}, Se = (s, e, t, i) => (ri(s, e, "write to private field"), i ? i.call(s, t) : e.set(s, t), t);
|
|
10
10
|
/**
|
|
11
11
|
* @license
|
|
12
12
|
* Copyright 2019 Google LLC
|
|
@@ -60,10 +60,10 @@ const gn = (s) => new Oi(typeof s == "string" ? s : s + "", void 0, Zs), rt = (s
|
|
|
60
60
|
* Copyright 2017 Google LLC
|
|
61
61
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
62
62
|
*/
|
|
63
|
-
const { is: vn, defineProperty: bn, getOwnPropertyDescriptor: wn, getOwnPropertyNames: _n, getOwnPropertySymbols: xn, getPrototypeOf: kn } = Object, tt = globalThis, ci = tt.trustedTypes,
|
|
63
|
+
const { is: vn, defineProperty: bn, getOwnPropertyDescriptor: wn, getOwnPropertyNames: _n, getOwnPropertySymbols: xn, getPrototypeOf: kn } = Object, tt = globalThis, ci = tt.trustedTypes, Tn = ci ? ci.emptyScript : "", di = tt.reactiveElementPolyfillSupport, lt = (s, e) => s, Ut = { toAttribute(s, e) {
|
|
64
64
|
switch (e) {
|
|
65
65
|
case Boolean:
|
|
66
|
-
s = s ?
|
|
66
|
+
s = s ? Tn : null;
|
|
67
67
|
break;
|
|
68
68
|
case Object:
|
|
69
69
|
case Array:
|
|
@@ -307,7 +307,7 @@ Ge.elementStyles = [], Ge.shadowRootOptions = { mode: "open" }, Ge[lt("elementPr
|
|
|
307
307
|
* Copyright 2017 Google LLC
|
|
308
308
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
309
309
|
*/
|
|
310
|
-
const Ht = globalThis, Bt = Ht.trustedTypes, ui = Bt ? Bt.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, zs = "$lit$", we = `lit$${(Math.random() + "").slice(9)}$`, Ds = "?" + we,
|
|
310
|
+
const Ht = globalThis, Bt = Ht.trustedTypes, ui = Bt ? Bt.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, zs = "$lit$", we = `lit$${(Math.random() + "").slice(9)}$`, Ds = "?" + we, Sn = `<${Ds}>`, He = document, gt = () => He.createComment(""), yt = (s) => s === null || typeof s != "object" && typeof s != "function", Ii = Array.isArray, Mi = (s) => Ii(s) || typeof (s == null ? void 0 : s[Symbol.iterator]) == "function", Es = `[
|
|
311
311
|
\f\r]`, ct = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, hi = /-->/g, pi = />/g, je = RegExp(`>|${Es}(?:([^\\s"'>=/]+)(${Es}*=${Es}*(?:[^
|
|
312
312
|
\f\r"'\`<>=]|("|')|))|$)`, "g"), mi = /'/g, fi = /"/g, Ni = /^(?:script|style|textarea|title)$/i, $n = (s) => (e, ...t) => ({ _$litType$: s, strings: e, values: t }), z = $n(1), le = Symbol.for("lit-noChange"), B = Symbol.for("lit-nothing"), gi = /* @__PURE__ */ new WeakMap(), Le = He.createTreeWalker(He, 129);
|
|
313
313
|
function Pi(s, e) {
|
|
@@ -324,7 +324,7 @@ const ji = (s, e) => {
|
|
|
324
324
|
for (; d < c.length && (a.lastIndex = d, h = a.exec(c), h !== null); )
|
|
325
325
|
d = a.lastIndex, a === ct ? h[1] === "!--" ? a = hi : h[1] !== void 0 ? a = pi : h[2] !== void 0 ? (Ni.test(h[2]) && (n = RegExp("</" + h[2], "g")), a = je) : h[3] !== void 0 && (a = je) : a === je ? h[0] === ">" ? (a = n ?? ct, p = -1) : h[1] === void 0 ? p = -2 : (p = a.lastIndex - h[2].length, l = h[1], a = h[3] === void 0 ? je : h[3] === '"' ? fi : mi) : a === fi || a === mi ? a = je : a === hi || a === pi ? a = ct : (a = je, n = void 0);
|
|
326
326
|
const b = a === je && s[o + 1].startsWith("/>") ? " " : "";
|
|
327
|
-
r += a === ct ? c +
|
|
327
|
+
r += a === ct ? c + Sn : p >= 0 ? (i.push(l), c.slice(0, p) + zs + c.slice(p) + we + b) : c + we + (p === -2 ? o : b);
|
|
328
328
|
}
|
|
329
329
|
return [Pi(s, r + (s[t] || "<?>") + (e === 2 ? "</svg>" : "")), i];
|
|
330
330
|
};
|
|
@@ -1196,7 +1196,7 @@ class I {
|
|
|
1196
1196
|
_refinement(e) {
|
|
1197
1197
|
return new ae({
|
|
1198
1198
|
schema: this,
|
|
1199
|
-
typeName:
|
|
1199
|
+
typeName: S.ZodEffects,
|
|
1200
1200
|
effect: { type: "refinement", refinement: e }
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
@@ -1219,16 +1219,16 @@ class I {
|
|
|
1219
1219
|
return it.create(this, this._def);
|
|
1220
1220
|
}
|
|
1221
1221
|
or(e) {
|
|
1222
|
-
return
|
|
1222
|
+
return Tt.create([this, e], this._def);
|
|
1223
1223
|
}
|
|
1224
1224
|
and(e) {
|
|
1225
|
-
return
|
|
1225
|
+
return St.create(this, e, this._def);
|
|
1226
1226
|
}
|
|
1227
1227
|
transform(e) {
|
|
1228
1228
|
return new ae({
|
|
1229
1229
|
...A(this._def),
|
|
1230
1230
|
schema: this,
|
|
1231
|
-
typeName:
|
|
1231
|
+
typeName: S.ZodEffects,
|
|
1232
1232
|
effect: { type: "transform", transform: e }
|
|
1233
1233
|
});
|
|
1234
1234
|
}
|
|
@@ -1238,12 +1238,12 @@ class I {
|
|
|
1238
1238
|
...A(this._def),
|
|
1239
1239
|
innerType: this,
|
|
1240
1240
|
defaultValue: t,
|
|
1241
|
-
typeName:
|
|
1241
|
+
typeName: S.ZodDefault
|
|
1242
1242
|
});
|
|
1243
1243
|
}
|
|
1244
1244
|
brand() {
|
|
1245
1245
|
return new Vi({
|
|
1246
|
-
typeName:
|
|
1246
|
+
typeName: S.ZodBranded,
|
|
1247
1247
|
type: this,
|
|
1248
1248
|
...A(this._def)
|
|
1249
1249
|
});
|
|
@@ -1254,7 +1254,7 @@ class I {
|
|
|
1254
1254
|
...A(this._def),
|
|
1255
1255
|
innerType: this,
|
|
1256
1256
|
catchValue: t,
|
|
1257
|
-
typeName:
|
|
1257
|
+
typeName: S.ZodCatch
|
|
1258
1258
|
});
|
|
1259
1259
|
}
|
|
1260
1260
|
describe(e) {
|
|
@@ -1579,7 +1579,7 @@ ie.create = (s) => {
|
|
|
1579
1579
|
var e;
|
|
1580
1580
|
return new ie({
|
|
1581
1581
|
checks: [],
|
|
1582
|
-
typeName:
|
|
1582
|
+
typeName: S.ZodString,
|
|
1583
1583
|
coerce: (e = s == null ? void 0 : s.coerce) !== null && e !== void 0 ? e : !1,
|
|
1584
1584
|
...A(s)
|
|
1585
1585
|
});
|
|
@@ -1756,7 +1756,7 @@ class Ce extends I {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
Ce.create = (s) => new Ce({
|
|
1758
1758
|
checks: [],
|
|
1759
|
-
typeName:
|
|
1759
|
+
typeName: S.ZodNumber,
|
|
1760
1760
|
coerce: (s == null ? void 0 : s.coerce) || !1,
|
|
1761
1761
|
...A(s)
|
|
1762
1762
|
});
|
|
@@ -1883,7 +1883,7 @@ Ae.create = (s) => {
|
|
|
1883
1883
|
var e;
|
|
1884
1884
|
return new Ae({
|
|
1885
1885
|
checks: [],
|
|
1886
|
-
typeName:
|
|
1886
|
+
typeName: S.ZodBigInt,
|
|
1887
1887
|
coerce: (e = s == null ? void 0 : s.coerce) !== null && e !== void 0 ? e : !1,
|
|
1888
1888
|
...A(s)
|
|
1889
1889
|
});
|
|
@@ -1902,7 +1902,7 @@ class _t extends I {
|
|
|
1902
1902
|
}
|
|
1903
1903
|
}
|
|
1904
1904
|
_t.create = (s) => new _t({
|
|
1905
|
-
typeName:
|
|
1905
|
+
typeName: S.ZodBoolean,
|
|
1906
1906
|
coerce: (s == null ? void 0 : s.coerce) || !1,
|
|
1907
1907
|
...A(s)
|
|
1908
1908
|
});
|
|
@@ -1981,7 +1981,7 @@ class Fe extends I {
|
|
|
1981
1981
|
Fe.create = (s) => new Fe({
|
|
1982
1982
|
checks: [],
|
|
1983
1983
|
coerce: (s == null ? void 0 : s.coerce) || !1,
|
|
1984
|
-
typeName:
|
|
1984
|
+
typeName: S.ZodDate,
|
|
1985
1985
|
...A(s)
|
|
1986
1986
|
});
|
|
1987
1987
|
class Kt extends I {
|
|
@@ -1998,7 +1998,7 @@ class Kt extends I {
|
|
|
1998
1998
|
}
|
|
1999
1999
|
}
|
|
2000
2000
|
Kt.create = (s) => new Kt({
|
|
2001
|
-
typeName:
|
|
2001
|
+
typeName: S.ZodSymbol,
|
|
2002
2002
|
...A(s)
|
|
2003
2003
|
});
|
|
2004
2004
|
class xt extends I {
|
|
@@ -2015,7 +2015,7 @@ class xt extends I {
|
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
2017
|
xt.create = (s) => new xt({
|
|
2018
|
-
typeName:
|
|
2018
|
+
typeName: S.ZodUndefined,
|
|
2019
2019
|
...A(s)
|
|
2020
2020
|
});
|
|
2021
2021
|
class kt extends I {
|
|
@@ -2032,7 +2032,7 @@ class kt extends I {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
}
|
|
2034
2034
|
kt.create = (s) => new kt({
|
|
2035
|
-
typeName:
|
|
2035
|
+
typeName: S.ZodNull,
|
|
2036
2036
|
...A(s)
|
|
2037
2037
|
});
|
|
2038
2038
|
class st extends I {
|
|
@@ -2044,7 +2044,7 @@ class st extends I {
|
|
|
2044
2044
|
}
|
|
2045
2045
|
}
|
|
2046
2046
|
st.create = (s) => new st({
|
|
2047
|
-
typeName:
|
|
2047
|
+
typeName: S.ZodAny,
|
|
2048
2048
|
...A(s)
|
|
2049
2049
|
});
|
|
2050
2050
|
class De extends I {
|
|
@@ -2056,7 +2056,7 @@ class De extends I {
|
|
|
2056
2056
|
}
|
|
2057
2057
|
}
|
|
2058
2058
|
De.create = (s) => new De({
|
|
2059
|
-
typeName:
|
|
2059
|
+
typeName: S.ZodUnknown,
|
|
2060
2060
|
...A(s)
|
|
2061
2061
|
});
|
|
2062
2062
|
class xe extends I {
|
|
@@ -2070,7 +2070,7 @@ class xe extends I {
|
|
|
2070
2070
|
}
|
|
2071
2071
|
}
|
|
2072
2072
|
xe.create = (s) => new xe({
|
|
2073
|
-
typeName:
|
|
2073
|
+
typeName: S.ZodNever,
|
|
2074
2074
|
...A(s)
|
|
2075
2075
|
});
|
|
2076
2076
|
class Jt extends I {
|
|
@@ -2087,7 +2087,7 @@ class Jt extends I {
|
|
|
2087
2087
|
}
|
|
2088
2088
|
}
|
|
2089
2089
|
Jt.create = (s) => new Jt({
|
|
2090
|
-
typeName:
|
|
2090
|
+
typeName: S.ZodVoid,
|
|
2091
2091
|
...A(s)
|
|
2092
2092
|
});
|
|
2093
2093
|
class re extends I {
|
|
@@ -2160,7 +2160,7 @@ re.create = (s, e) => new re({
|
|
|
2160
2160
|
minLength: null,
|
|
2161
2161
|
maxLength: null,
|
|
2162
2162
|
exactLength: null,
|
|
2163
|
-
typeName:
|
|
2163
|
+
typeName: S.ZodArray,
|
|
2164
2164
|
...A(e)
|
|
2165
2165
|
});
|
|
2166
2166
|
function Xe(s) {
|
|
@@ -2325,7 +2325,7 @@ class H extends I {
|
|
|
2325
2325
|
...this._def.shape(),
|
|
2326
2326
|
...e._def.shape()
|
|
2327
2327
|
}),
|
|
2328
|
-
typeName:
|
|
2328
|
+
typeName: S.ZodObject
|
|
2329
2329
|
});
|
|
2330
2330
|
}
|
|
2331
2331
|
// merge<
|
|
@@ -2451,24 +2451,24 @@ H.create = (s, e) => new H({
|
|
|
2451
2451
|
shape: () => s,
|
|
2452
2452
|
unknownKeys: "strip",
|
|
2453
2453
|
catchall: xe.create(),
|
|
2454
|
-
typeName:
|
|
2454
|
+
typeName: S.ZodObject,
|
|
2455
2455
|
...A(e)
|
|
2456
2456
|
});
|
|
2457
2457
|
H.strictCreate = (s, e) => new H({
|
|
2458
2458
|
shape: () => s,
|
|
2459
2459
|
unknownKeys: "strict",
|
|
2460
2460
|
catchall: xe.create(),
|
|
2461
|
-
typeName:
|
|
2461
|
+
typeName: S.ZodObject,
|
|
2462
2462
|
...A(e)
|
|
2463
2463
|
});
|
|
2464
2464
|
H.lazycreate = (s, e) => new H({
|
|
2465
2465
|
shape: s,
|
|
2466
2466
|
unknownKeys: "strip",
|
|
2467
2467
|
catchall: xe.create(),
|
|
2468
|
-
typeName:
|
|
2468
|
+
typeName: S.ZodObject,
|
|
2469
2469
|
...A(e)
|
|
2470
2470
|
});
|
|
2471
|
-
class
|
|
2471
|
+
class Tt extends I {
|
|
2472
2472
|
_parse(e) {
|
|
2473
2473
|
const { ctx: t } = this._processInputParams(e), i = this._def.options;
|
|
2474
2474
|
function n(r) {
|
|
@@ -2536,9 +2536,9 @@ class St extends I {
|
|
|
2536
2536
|
return this._def.options;
|
|
2537
2537
|
}
|
|
2538
2538
|
}
|
|
2539
|
-
|
|
2539
|
+
Tt.create = (s, e) => new Tt({
|
|
2540
2540
|
options: s,
|
|
2541
|
-
typeName:
|
|
2541
|
+
typeName: S.ZodUnion,
|
|
2542
2542
|
...A(e)
|
|
2543
2543
|
});
|
|
2544
2544
|
const zt = (s) => s instanceof Et ? zt(s.schema) : s instanceof ae ? zt(s.innerType()) : s instanceof Ct ? [s.value] : s instanceof Oe ? s.options : s instanceof At ? Object.keys(s.enum) : s instanceof Ot ? zt(s._def.innerType) : s instanceof xt ? [void 0] : s instanceof kt ? [null] : null;
|
|
@@ -2596,7 +2596,7 @@ class ds extends I {
|
|
|
2596
2596
|
}
|
|
2597
2597
|
}
|
|
2598
2598
|
return new ds({
|
|
2599
|
-
typeName:
|
|
2599
|
+
typeName: S.ZodDiscriminatedUnion,
|
|
2600
2600
|
discriminator: e,
|
|
2601
2601
|
options: t,
|
|
2602
2602
|
optionsMap: n,
|
|
@@ -2631,7 +2631,7 @@ function Ns(s, e) {
|
|
|
2631
2631
|
} else
|
|
2632
2632
|
return t === f.date && i === f.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
|
|
2633
2633
|
}
|
|
2634
|
-
class
|
|
2634
|
+
class St extends I {
|
|
2635
2635
|
_parse(e) {
|
|
2636
2636
|
const { status: t, ctx: i } = this._processInputParams(e), n = (r, a) => {
|
|
2637
2637
|
if (Is(r) || Is(a))
|
|
@@ -2663,10 +2663,10 @@ class Tt extends I {
|
|
|
2663
2663
|
}));
|
|
2664
2664
|
}
|
|
2665
2665
|
}
|
|
2666
|
-
|
|
2666
|
+
St.create = (s, e, t) => new St({
|
|
2667
2667
|
left: s,
|
|
2668
2668
|
right: e,
|
|
2669
|
-
typeName:
|
|
2669
|
+
typeName: S.ZodIntersection,
|
|
2670
2670
|
...A(t)
|
|
2671
2671
|
});
|
|
2672
2672
|
class he extends I {
|
|
@@ -2714,7 +2714,7 @@ he.create = (s, e) => {
|
|
|
2714
2714
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2715
2715
|
return new he({
|
|
2716
2716
|
items: s,
|
|
2717
|
-
typeName:
|
|
2717
|
+
typeName: S.ZodTuple,
|
|
2718
2718
|
rest: null,
|
|
2719
2719
|
...A(e)
|
|
2720
2720
|
});
|
|
@@ -2749,12 +2749,12 @@ class $t extends I {
|
|
|
2749
2749
|
return t instanceof I ? new $t({
|
|
2750
2750
|
keyType: e,
|
|
2751
2751
|
valueType: t,
|
|
2752
|
-
typeName:
|
|
2752
|
+
typeName: S.ZodRecord,
|
|
2753
2753
|
...A(i)
|
|
2754
2754
|
}) : new $t({
|
|
2755
2755
|
keyType: ie.create(),
|
|
2756
2756
|
valueType: e,
|
|
2757
|
-
typeName:
|
|
2757
|
+
typeName: S.ZodRecord,
|
|
2758
2758
|
...A(t)
|
|
2759
2759
|
});
|
|
2760
2760
|
}
|
|
@@ -2804,7 +2804,7 @@ class qt extends I {
|
|
|
2804
2804
|
qt.create = (s, e, t) => new qt({
|
|
2805
2805
|
valueType: e,
|
|
2806
2806
|
keyType: s,
|
|
2807
|
-
typeName:
|
|
2807
|
+
typeName: S.ZodMap,
|
|
2808
2808
|
...A(t)
|
|
2809
2809
|
});
|
|
2810
2810
|
class Ve extends I {
|
|
@@ -2868,7 +2868,7 @@ Ve.create = (s, e) => new Ve({
|
|
|
2868
2868
|
valueType: s,
|
|
2869
2869
|
minSize: null,
|
|
2870
2870
|
maxSize: null,
|
|
2871
|
-
typeName:
|
|
2871
|
+
typeName: S.ZodSet,
|
|
2872
2872
|
...A(e)
|
|
2873
2873
|
});
|
|
2874
2874
|
class Qe extends I {
|
|
@@ -2967,7 +2967,7 @@ class Qe extends I {
|
|
|
2967
2967
|
return new Qe({
|
|
2968
2968
|
args: e || he.create([]).rest(De.create()),
|
|
2969
2969
|
returns: t || De.create(),
|
|
2970
|
-
typeName:
|
|
2970
|
+
typeName: S.ZodFunction,
|
|
2971
2971
|
...A(i)
|
|
2972
2972
|
});
|
|
2973
2973
|
}
|
|
@@ -2983,7 +2983,7 @@ class Et extends I {
|
|
|
2983
2983
|
}
|
|
2984
2984
|
Et.create = (s, e) => new Et({
|
|
2985
2985
|
getter: s,
|
|
2986
|
-
typeName:
|
|
2986
|
+
typeName: S.ZodLazy,
|
|
2987
2987
|
...A(e)
|
|
2988
2988
|
});
|
|
2989
2989
|
class Ct extends I {
|
|
@@ -3004,13 +3004,13 @@ class Ct extends I {
|
|
|
3004
3004
|
}
|
|
3005
3005
|
Ct.create = (s, e) => new Ct({
|
|
3006
3006
|
value: s,
|
|
3007
|
-
typeName:
|
|
3007
|
+
typeName: S.ZodLiteral,
|
|
3008
3008
|
...A(e)
|
|
3009
3009
|
});
|
|
3010
3010
|
function Fi(s, e) {
|
|
3011
3011
|
return new Oe({
|
|
3012
3012
|
values: s,
|
|
3013
|
-
typeName:
|
|
3013
|
+
typeName: S.ZodEnum,
|
|
3014
3014
|
...A(e)
|
|
3015
3015
|
});
|
|
3016
3016
|
}
|
|
@@ -3090,7 +3090,7 @@ class At extends I {
|
|
|
3090
3090
|
}
|
|
3091
3091
|
At.create = (s, e) => new At({
|
|
3092
3092
|
values: s,
|
|
3093
|
-
typeName:
|
|
3093
|
+
typeName: S.ZodNativeEnum,
|
|
3094
3094
|
...A(e)
|
|
3095
3095
|
});
|
|
3096
3096
|
class it extends I {
|
|
@@ -3114,7 +3114,7 @@ class it extends I {
|
|
|
3114
3114
|
}
|
|
3115
3115
|
it.create = (s, e) => new it({
|
|
3116
3116
|
type: s,
|
|
3117
|
-
typeName:
|
|
3117
|
+
typeName: S.ZodPromise,
|
|
3118
3118
|
...A(e)
|
|
3119
3119
|
});
|
|
3120
3120
|
class ae extends I {
|
|
@@ -3122,7 +3122,7 @@ class ae extends I {
|
|
|
3122
3122
|
return this._def.schema;
|
|
3123
3123
|
}
|
|
3124
3124
|
sourceType() {
|
|
3125
|
-
return this._def.schema._def.typeName ===
|
|
3125
|
+
return this._def.schema._def.typeName === S.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3126
3126
|
}
|
|
3127
3127
|
_parse(e) {
|
|
3128
3128
|
const { status: t, ctx: i } = this._processInputParams(e), n = this._def.effect || null, r = {
|
|
@@ -3187,14 +3187,14 @@ class ae extends I {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
ae.create = (s, e, t) => new ae({
|
|
3189
3189
|
schema: s,
|
|
3190
|
-
typeName:
|
|
3190
|
+
typeName: S.ZodEffects,
|
|
3191
3191
|
effect: e,
|
|
3192
3192
|
...A(t)
|
|
3193
3193
|
});
|
|
3194
3194
|
ae.createWithPreprocess = (s, e, t) => new ae({
|
|
3195
3195
|
schema: e,
|
|
3196
3196
|
effect: { type: "preprocess", transform: s },
|
|
3197
|
-
typeName:
|
|
3197
|
+
typeName: S.ZodEffects,
|
|
3198
3198
|
...A(t)
|
|
3199
3199
|
});
|
|
3200
3200
|
class _e extends I {
|
|
@@ -3207,7 +3207,7 @@ class _e extends I {
|
|
|
3207
3207
|
}
|
|
3208
3208
|
_e.create = (s, e) => new _e({
|
|
3209
3209
|
innerType: s,
|
|
3210
|
-
typeName:
|
|
3210
|
+
typeName: S.ZodOptional,
|
|
3211
3211
|
...A(e)
|
|
3212
3212
|
});
|
|
3213
3213
|
class We extends I {
|
|
@@ -3220,7 +3220,7 @@ class We extends I {
|
|
|
3220
3220
|
}
|
|
3221
3221
|
We.create = (s, e) => new We({
|
|
3222
3222
|
innerType: s,
|
|
3223
|
-
typeName:
|
|
3223
|
+
typeName: S.ZodNullable,
|
|
3224
3224
|
...A(e)
|
|
3225
3225
|
});
|
|
3226
3226
|
class Ot extends I {
|
|
@@ -3239,7 +3239,7 @@ class Ot extends I {
|
|
|
3239
3239
|
}
|
|
3240
3240
|
Ot.create = (s, e) => new Ot({
|
|
3241
3241
|
innerType: s,
|
|
3242
|
-
typeName:
|
|
3242
|
+
typeName: S.ZodDefault,
|
|
3243
3243
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
3244
3244
|
...A(e)
|
|
3245
3245
|
});
|
|
@@ -3282,7 +3282,7 @@ class Yt extends I {
|
|
|
3282
3282
|
}
|
|
3283
3283
|
Yt.create = (s, e) => new Yt({
|
|
3284
3284
|
innerType: s,
|
|
3285
|
-
typeName:
|
|
3285
|
+
typeName: S.ZodCatch,
|
|
3286
3286
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3287
3287
|
...A(e)
|
|
3288
3288
|
});
|
|
@@ -3300,7 +3300,7 @@ class Gt extends I {
|
|
|
3300
3300
|
}
|
|
3301
3301
|
}
|
|
3302
3302
|
Gt.create = (s) => new Gt({
|
|
3303
|
-
typeName:
|
|
3303
|
+
typeName: S.ZodNaN,
|
|
3304
3304
|
...A(s)
|
|
3305
3305
|
});
|
|
3306
3306
|
const Kn = Symbol("zod_brand");
|
|
@@ -3353,7 +3353,7 @@ class Nt extends I {
|
|
|
3353
3353
|
return new Nt({
|
|
3354
3354
|
in: e,
|
|
3355
3355
|
out: t,
|
|
3356
|
-
typeName:
|
|
3356
|
+
typeName: S.ZodPipeline
|
|
3357
3357
|
});
|
|
3358
3358
|
}
|
|
3359
3359
|
}
|
|
@@ -3365,7 +3365,7 @@ class Xt extends I {
|
|
|
3365
3365
|
}
|
|
3366
3366
|
Xt.create = (s, e) => new Xt({
|
|
3367
3367
|
innerType: s,
|
|
3368
|
-
typeName:
|
|
3368
|
+
typeName: S.ZodReadonly,
|
|
3369
3369
|
...A(e)
|
|
3370
3370
|
});
|
|
3371
3371
|
const Wi = (s, e = {}, t) => s ? st.create().superRefine((i, n) => {
|
|
@@ -3377,13 +3377,13 @@ const Wi = (s, e = {}, t) => s ? st.create().superRefine((i, n) => {
|
|
|
3377
3377
|
}) : st.create(), Jn = {
|
|
3378
3378
|
object: H.lazycreate
|
|
3379
3379
|
};
|
|
3380
|
-
var
|
|
3380
|
+
var S;
|
|
3381
3381
|
(function(s) {
|
|
3382
3382
|
s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
|
|
3383
|
-
})(
|
|
3383
|
+
})(S || (S = {}));
|
|
3384
3384
|
const qn = (s, e = {
|
|
3385
3385
|
message: `Input not instance of ${s.name}`
|
|
3386
|
-
}) => Wi((t) => t instanceof s, e), Ki = ie.create, Ji = Ce.create, Yn = Gt.create, Gn = Ae.create, qi = _t.create, Xn = Fe.create, Qn = Kt.create, er = xt.create, tr = kt.create, sr = st.create, ir = De.create, nr = xe.create, rr = Jt.create, ar = re.create, or = H.create, cr = H.strictCreate, dr =
|
|
3386
|
+
}) => Wi((t) => t instanceof s, e), Ki = ie.create, Ji = Ce.create, Yn = Gt.create, Gn = Ae.create, qi = _t.create, Xn = Fe.create, Qn = Kt.create, er = xt.create, tr = kt.create, sr = st.create, ir = De.create, nr = xe.create, rr = Jt.create, ar = re.create, or = H.create, cr = H.strictCreate, dr = Tt.create, lr = ds.create, ur = St.create, hr = he.create, pr = $t.create, mr = qt.create, fr = Ve.create, gr = Qe.create, yr = Et.create, vr = Ct.create, br = Oe.create, wr = At.create, _r = it.create, ki = ae.create, xr = _e.create, kr = We.create, Tr = ae.createWithPreprocess, Sr = Nt.create, $r = () => Ki().optional(), Er = () => Ji().optional(), Cr = () => qi().optional(), Ar = {
|
|
3387
3387
|
string: (s) => ie.create({ ...s, coerce: !0 }),
|
|
3388
3388
|
number: (s) => Ce.create({ ...s, coerce: !0 }),
|
|
3389
3389
|
boolean: (s) => _t.create({
|
|
@@ -3432,9 +3432,9 @@ var w = /* @__PURE__ */ Object.freeze({
|
|
|
3432
3432
|
ZodVoid: Jt,
|
|
3433
3433
|
ZodArray: re,
|
|
3434
3434
|
ZodObject: H,
|
|
3435
|
-
ZodUnion:
|
|
3435
|
+
ZodUnion: Tt,
|
|
3436
3436
|
ZodDiscriminatedUnion: ds,
|
|
3437
|
-
ZodIntersection:
|
|
3437
|
+
ZodIntersection: St,
|
|
3438
3438
|
ZodTuple: he,
|
|
3439
3439
|
ZodRecord: $t,
|
|
3440
3440
|
ZodMap: qt,
|
|
@@ -3461,7 +3461,7 @@ var w = /* @__PURE__ */ Object.freeze({
|
|
|
3461
3461
|
ZodSchema: I,
|
|
3462
3462
|
late: Jn,
|
|
3463
3463
|
get ZodFirstPartyTypeKind() {
|
|
3464
|
-
return
|
|
3464
|
+
return S;
|
|
3465
3465
|
},
|
|
3466
3466
|
coerce: Ar,
|
|
3467
3467
|
any: sr,
|
|
@@ -3489,8 +3489,8 @@ var w = /* @__PURE__ */ Object.freeze({
|
|
|
3489
3489
|
onumber: Er,
|
|
3490
3490
|
optional: xr,
|
|
3491
3491
|
ostring: $r,
|
|
3492
|
-
pipeline:
|
|
3493
|
-
preprocess:
|
|
3492
|
+
pipeline: Sr,
|
|
3493
|
+
preprocess: Tr,
|
|
3494
3494
|
promise: _r,
|
|
3495
3495
|
record: pr,
|
|
3496
3496
|
set: fr,
|
|
@@ -3514,6 +3514,7 @@ const ls = w.object({
|
|
|
3514
3514
|
config: w.object({
|
|
3515
3515
|
historyKey: w.string().refine((s) => s.replace(/-/g, "_")).nullable().default("main"),
|
|
3516
3516
|
welcomeMessage: w.string().default("Hello! How can I help you today?"),
|
|
3517
|
+
initialReplyMessage: w.string().nullable().default(null),
|
|
3517
3518
|
placement: w.enum(["left", "right"]).default("right"),
|
|
3518
3519
|
openChatButton: w.object({
|
|
3519
3520
|
imageSrc: w.string().optional(),
|
|
@@ -3574,12 +3575,12 @@ function Ir(s) {
|
|
|
3574
3575
|
}
|
|
3575
3576
|
var Us = !1;
|
|
3576
3577
|
if (typeof window < "u") {
|
|
3577
|
-
var
|
|
3578
|
+
var Ti = {
|
|
3578
3579
|
get passive() {
|
|
3579
3580
|
Us = !0;
|
|
3580
3581
|
}
|
|
3581
3582
|
};
|
|
3582
|
-
window.addEventListener("testPassive", null,
|
|
3583
|
+
window.addEventListener("testPassive", null, Ti), window.removeEventListener("testPassive", null, Ti);
|
|
3583
3584
|
}
|
|
3584
3585
|
var Qt = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1), Ue = [], es = !1, Yi = -1, ht = void 0, Ze = void 0, pt = void 0, Gi = function(s) {
|
|
3585
3586
|
return Ue.some(function(e) {
|
|
@@ -3644,7 +3645,7 @@ var Qt = typeof window < "u" && window.navigator && window.navigator.platform &&
|
|
|
3644
3645
|
i.targetTouches.length === 1 && Zr(i, s);
|
|
3645
3646
|
}, es || (document.addEventListener("touchmove", Hs, Us ? { passive: !1 } : void 0), es = !0));
|
|
3646
3647
|
}
|
|
3647
|
-
},
|
|
3648
|
+
}, Si = function(s) {
|
|
3648
3649
|
if (!s) {
|
|
3649
3650
|
console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");
|
|
3650
3651
|
return;
|
|
@@ -3720,14 +3721,14 @@ var Dr = Object.defineProperty, Ur = Object.getOwnPropertyDescriptor, Pt = (s, e
|
|
|
3720
3721
|
let Ke = class extends Q {
|
|
3721
3722
|
constructor() {
|
|
3722
3723
|
super(...arguments), this.isOpen = !0, this.onResizeHandler = () => {
|
|
3723
|
-
this.isOpen && window.innerWidth < 768 ? Lr(this) :
|
|
3724
|
+
this.isOpen && window.innerWidth < 768 ? Lr(this) : Si(this);
|
|
3724
3725
|
};
|
|
3725
3726
|
}
|
|
3726
3727
|
connectedCallback() {
|
|
3727
3728
|
super.connectedCallback(), this.cleanOptions = ls.parse(this.options), this.onResizeHandler(), window.addEventListener("resize", this.onResizeHandler, { passive: !0 });
|
|
3728
3729
|
}
|
|
3729
3730
|
disconnectedCallback() {
|
|
3730
|
-
super.disconnectedCallback(),
|
|
3731
|
+
super.disconnectedCallback(), Si(this), window.removeEventListener("resize", this.onResizeHandler);
|
|
3731
3732
|
}
|
|
3732
3733
|
render() {
|
|
3733
3734
|
const s = this.cleanOptions.config.placement !== "left", e = _i({
|
|
@@ -3846,56 +3847,60 @@ function Vr(s) {
|
|
|
3846
3847
|
});
|
|
3847
3848
|
} };
|
|
3848
3849
|
}
|
|
3849
|
-
|
|
3850
|
-
constructor(
|
|
3851
|
-
this._assistantId = "", this.
|
|
3852
|
-
var
|
|
3853
|
-
const [
|
|
3854
|
-
if (!(
|
|
3855
|
-
switch (
|
|
3850
|
+
let Wr = class {
|
|
3851
|
+
constructor(s, e = {}) {
|
|
3852
|
+
if (this._assistantId = "", this._threadId = "", this._messages = [], this.isTyping = !1, this.inputDisabled = !1, this.onStorageEvent = (t) => {
|
|
3853
|
+
var i;
|
|
3854
|
+
const [n, r, a] = ((i = t.key) == null ? void 0 : i.split("-")) || [];
|
|
3855
|
+
if (!(n !== "iaiChat" || r !== this.options.historyKey))
|
|
3856
|
+
switch (a) {
|
|
3856
3857
|
case "messageHistory":
|
|
3857
|
-
this.onMessageHistoryStorageEvent(
|
|
3858
|
+
this.onMessageHistoryStorageEvent(t);
|
|
3858
3859
|
break;
|
|
3859
3860
|
case "threadId":
|
|
3860
|
-
this.setThreadId(JSON.parse(
|
|
3861
|
+
this.setThreadId(JSON.parse(t.newValue || ""), !0);
|
|
3861
3862
|
break;
|
|
3862
3863
|
case "typing":
|
|
3863
|
-
this.setTyping(JSON.parse(
|
|
3864
|
+
this.setTyping(JSON.parse(t.newValue || "false"), !0);
|
|
3864
3865
|
break;
|
|
3865
3866
|
case "inputDisabled":
|
|
3866
|
-
this.setInputDisabled(JSON.parse(
|
|
3867
|
+
this.setInputDisabled(JSON.parse(t.newValue || "false"), !0);
|
|
3867
3868
|
break;
|
|
3868
3869
|
}
|
|
3869
|
-
}, this._assistantId =
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
const
|
|
3877
|
-
|
|
3878
|
-
const
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
this.
|
|
3870
|
+
}, this._assistantId = s, this.options = {
|
|
3871
|
+
params: {},
|
|
3872
|
+
simulateDelays: !0,
|
|
3873
|
+
historyKey: null,
|
|
3874
|
+
initialReplyMessage: null,
|
|
3875
|
+
...e
|
|
3876
|
+
}, this._emitter = Vr(), this.on = this._emitter.on.bind(this._emitter), this.off = this._emitter.off.bind(this._emitter), e.historyKey) {
|
|
3877
|
+
const t = this.storageGet("messageHistory");
|
|
3878
|
+
t && (this._messages = t);
|
|
3879
|
+
const i = this.storageGet("threadId");
|
|
3880
|
+
i && this.setThreadId(i, !0);
|
|
3881
|
+
const n = this.storageGet("typing");
|
|
3882
|
+
n && this.setTyping(n, !0);
|
|
3883
|
+
const r = this.storageGet("inputDisabled");
|
|
3884
|
+
r && this.setInputDisabled(r, !0), window.addEventListener("storage", this.onStorageEvent);
|
|
3885
|
+
}
|
|
3886
|
+
e.events && Object.entries(e.events).forEach(([t, i]) => {
|
|
3887
|
+
this._emitter.on(t, i);
|
|
3883
3888
|
});
|
|
3884
3889
|
}
|
|
3885
|
-
onMessageHistoryStorageEvent(
|
|
3886
|
-
if (!
|
|
3890
|
+
onMessageHistoryStorageEvent(s) {
|
|
3891
|
+
if (!s.newValue) {
|
|
3887
3892
|
this.reset();
|
|
3888
3893
|
return;
|
|
3889
3894
|
}
|
|
3890
|
-
const
|
|
3891
|
-
this._messages.forEach((
|
|
3892
|
-
|
|
3893
|
-
}),
|
|
3894
|
-
|
|
3895
|
-
}), this._messages =
|
|
3895
|
+
const e = JSON.parse(s.newValue), t = this._messages.map((n) => n.id), i = e.map((n) => n.id);
|
|
3896
|
+
this._messages.forEach((n) => {
|
|
3897
|
+
i.includes(n.id) || this._emitter.emit("messageRemoved", n.id);
|
|
3898
|
+
}), e.forEach((n) => {
|
|
3899
|
+
t.includes(n.id) || this._emitter.emit("message", n);
|
|
3900
|
+
}), this._messages = e;
|
|
3896
3901
|
}
|
|
3897
3902
|
reset() {
|
|
3898
|
-
this._messages = [], this.setTyping(!1), this.setInputDisabled(!1), this.storageRemoveAll(), this._emitter.emit("reset");
|
|
3903
|
+
this._threadId = "", this._messages = [], this.setTyping(!1), this.setInputDisabled(!1), this.storageRemoveAll(), this._emitter.emit("reset");
|
|
3899
3904
|
}
|
|
3900
3905
|
destroy() {
|
|
3901
3906
|
this._emitter.all.clear(), window.removeEventListener("storage", this.onStorageEvent), this._emitter.emit("destroy");
|
|
@@ -3903,73 +3908,80 @@ class Wr {
|
|
|
3903
3908
|
async startChat() {
|
|
3904
3909
|
if (this.chatStarted)
|
|
3905
3910
|
return;
|
|
3906
|
-
const { id:
|
|
3907
|
-
this.setThreadId(
|
|
3911
|
+
const { id: s } = await Hr(this.assistantId, this.params);
|
|
3912
|
+
this.setThreadId(s);
|
|
3908
3913
|
}
|
|
3909
|
-
addMessage(
|
|
3910
|
-
const
|
|
3911
|
-
...
|
|
3912
|
-
id:
|
|
3914
|
+
addMessage(s) {
|
|
3915
|
+
const e = {
|
|
3916
|
+
...s,
|
|
3917
|
+
id: s.id || Math.random().toString(36).substring(7)
|
|
3913
3918
|
};
|
|
3914
|
-
return this._messages.push(
|
|
3919
|
+
return this._messages.push(e), this.storageSet("messageHistory", this._messages), this._emitter.emit("message", e), e;
|
|
3915
3920
|
}
|
|
3916
|
-
removeMessage(
|
|
3917
|
-
this._messages = this._messages.filter((
|
|
3921
|
+
removeMessage(s) {
|
|
3922
|
+
this._messages = this._messages.filter((e) => e.id !== s), this.storageSet("messageHistory", this._messages), this._emitter.emit("messageRemoved", s);
|
|
3918
3923
|
}
|
|
3919
|
-
async respondToFunctionCall(e, t
|
|
3924
|
+
async respondToFunctionCall(s, e, t) {
|
|
3920
3925
|
this.simulateDelay(1800).then(() => this.setTyping(!0));
|
|
3921
|
-
const
|
|
3926
|
+
const i = this.simulateDelay(2e3);
|
|
3922
3927
|
await this.insertMessagesWithSimulatedDelays(
|
|
3923
3928
|
Promise.all([
|
|
3924
|
-
Fr(this.threadId, e, t
|
|
3925
|
-
|
|
3926
|
-
]).then(([
|
|
3929
|
+
Fr(this.threadId, s, e, t),
|
|
3930
|
+
i
|
|
3931
|
+
]).then(([n]) => n)
|
|
3927
3932
|
);
|
|
3928
3933
|
}
|
|
3929
|
-
async sendUserMessage(
|
|
3934
|
+
async sendUserMessage(s) {
|
|
3930
3935
|
try {
|
|
3931
3936
|
this.addMessage({
|
|
3932
|
-
id: Math.random().toString(36).substring(7),
|
|
3933
3937
|
role: "user",
|
|
3934
|
-
content:
|
|
3938
|
+
content: s
|
|
3935
3939
|
}), this.simulateDelay(1800).then(() => this.setTyping(!0));
|
|
3936
|
-
|
|
3937
|
-
this.chatStarted
|
|
3938
|
-
|
|
3940
|
+
let e = this.simulateDelay(4800);
|
|
3941
|
+
if (!this.chatStarted) {
|
|
3942
|
+
const { initialReplyMessage: n } = this.options;
|
|
3943
|
+
n && (this.simulateDelay(3800).then(() => {
|
|
3944
|
+
this.addMessage({
|
|
3945
|
+
role: "assistant",
|
|
3946
|
+
content: n
|
|
3947
|
+
}), this.setTyping(!1);
|
|
3948
|
+
}), this.simulateDelay(6200).then(() => this.setTyping(!0)), e = this.simulateDelay(8200)), await this.startChat();
|
|
3949
|
+
}
|
|
3950
|
+
const { messages: t, functions: i } = await this.insertMessagesWithSimulatedDelays(
|
|
3939
3951
|
Promise.all([
|
|
3940
|
-
Br(this.threadId,
|
|
3941
|
-
|
|
3942
|
-
]).then(([
|
|
3952
|
+
Br(this.threadId, s),
|
|
3953
|
+
e
|
|
3954
|
+
]).then(([n]) => n)
|
|
3943
3955
|
);
|
|
3944
|
-
return { messages:
|
|
3945
|
-
} catch (
|
|
3946
|
-
throw console.error(
|
|
3956
|
+
return { messages: t, functions: i };
|
|
3957
|
+
} catch (e) {
|
|
3958
|
+
throw console.error(e), new Error("There was an error sending the message");
|
|
3947
3959
|
}
|
|
3948
3960
|
}
|
|
3949
|
-
setThreadId(
|
|
3950
|
-
this._threadId =
|
|
3961
|
+
setThreadId(s, e = !1) {
|
|
3962
|
+
this._threadId = s, e || this.storageSet("threadId", s);
|
|
3951
3963
|
}
|
|
3952
|
-
setTyping(
|
|
3953
|
-
this.isTyping =
|
|
3964
|
+
setTyping(s, e = !1) {
|
|
3965
|
+
this.isTyping = s, this._emitter.emit("typing", s), e || this.storageSet("typing", s);
|
|
3954
3966
|
}
|
|
3955
|
-
setInputDisabled(
|
|
3956
|
-
this.inputDisabled =
|
|
3967
|
+
setInputDisabled(s, e = !1) {
|
|
3968
|
+
this.inputDisabled = s, this._emitter.emit("inputDisabled", s), e || this.storageSet("inputDisabled", s);
|
|
3957
3969
|
}
|
|
3958
|
-
async insertMessagesWithSimulatedDelays(
|
|
3959
|
-
const
|
|
3960
|
-
if (
|
|
3961
|
-
throw new Error(
|
|
3962
|
-
const { messages:
|
|
3963
|
-
return await Promise.all(
|
|
3970
|
+
async insertMessagesWithSimulatedDelays(s) {
|
|
3971
|
+
const e = await s;
|
|
3972
|
+
if (e.error)
|
|
3973
|
+
throw new Error(e.message);
|
|
3974
|
+
const { messages: t, functions: i } = e;
|
|
3975
|
+
return await Promise.all(t.map(async (n, r) => (await this.simulateDelay(1e3 * r), this.addMessage(n)))), this.setTyping(!1), i.forEach((n) => this._emitter.emit("functionCall", n)), { messages: t, functions: i };
|
|
3964
3976
|
}
|
|
3965
|
-
simulateDelay(
|
|
3966
|
-
return this.
|
|
3977
|
+
simulateDelay(s) {
|
|
3978
|
+
return this.options.simulateDelays ? new Promise((e) => setTimeout(e, s)) : Promise.resolve();
|
|
3967
3979
|
}
|
|
3968
3980
|
get assistantId() {
|
|
3969
3981
|
return this._assistantId;
|
|
3970
3982
|
}
|
|
3971
3983
|
get params() {
|
|
3972
|
-
return this.
|
|
3984
|
+
return this.options.params;
|
|
3973
3985
|
}
|
|
3974
3986
|
get threadId() {
|
|
3975
3987
|
return this._threadId;
|
|
@@ -3980,24 +3992,24 @@ class Wr {
|
|
|
3980
3992
|
get chatStarted() {
|
|
3981
3993
|
return !!this._threadId;
|
|
3982
3994
|
}
|
|
3983
|
-
storageSet(
|
|
3984
|
-
this.
|
|
3995
|
+
storageSet(s, e) {
|
|
3996
|
+
this.options.historyKey && localStorage.setItem(`iaiChat-${this.options.historyKey}-${s}`, JSON.stringify(e));
|
|
3985
3997
|
}
|
|
3986
|
-
storageGet(
|
|
3987
|
-
if (!this.
|
|
3998
|
+
storageGet(s) {
|
|
3999
|
+
if (!this.options.historyKey)
|
|
3988
4000
|
return null;
|
|
3989
|
-
const
|
|
3990
|
-
return
|
|
4001
|
+
const e = localStorage.getItem(`iaiChat-${this.options.historyKey}-${s}`);
|
|
4002
|
+
return e ? JSON.parse(e) : null;
|
|
3991
4003
|
}
|
|
3992
|
-
storageRemove(
|
|
3993
|
-
localStorage.removeItem(`iaiChat-${this.
|
|
4004
|
+
storageRemove(s) {
|
|
4005
|
+
localStorage.removeItem(`iaiChat-${this.options.historyKey}-${s}`);
|
|
3994
4006
|
}
|
|
3995
4007
|
storageRemoveAll() {
|
|
3996
|
-
this.
|
|
3997
|
-
|
|
4008
|
+
this.options.historyKey && Object.keys(localStorage).forEach((s) => {
|
|
4009
|
+
s.startsWith(`iaiChat-${this.options.historyKey}-`) && localStorage.removeItem(s);
|
|
3998
4010
|
});
|
|
3999
4011
|
}
|
|
4000
|
-
}
|
|
4012
|
+
};
|
|
4001
4013
|
function Kr(s) {
|
|
4002
4014
|
return { all: s = s || /* @__PURE__ */ new Map(), on: function(e, t) {
|
|
4003
4015
|
var i = s.get(e);
|
|
@@ -4203,7 +4215,12 @@ let oe = class extends Q {
|
|
|
4203
4215
|
connectedCallback() {
|
|
4204
4216
|
super.connectedCallback(), this.cleanOptions = ls.parse(this.options || {});
|
|
4205
4217
|
const { assistantId: s, params: e, config: t } = this.cleanOptions;
|
|
4206
|
-
Ai(this, $e, new Wr(s, {
|
|
4218
|
+
Ai(this, $e, new Wr(s, {
|
|
4219
|
+
params: e,
|
|
4220
|
+
simulateDelays: !0,
|
|
4221
|
+
historyKey: t.historyKey,
|
|
4222
|
+
initialReplyMessage: t.initialReplyMessage
|
|
4223
|
+
})), this.updateMessages(Ye(this, $e).messages), this.showTyping = Ye(this, $e).isTyping, this.disableInput = Ye(this, $e).inputDisabled, this.chatManager.on("functionCall", ({ id: i, name: n, params: r }) => {
|
|
4207
4224
|
const a = this.cleanOptions.handlers.functionCalls[n];
|
|
4208
4225
|
if (!a) {
|
|
4209
4226
|
console.warn(`No function call handler found for ${n}`);
|
|
@@ -4608,7 +4625,7 @@ var en = { exports: {} };
|
|
|
4608
4625
|
function ye(v) {
|
|
4609
4626
|
return se.slice(se.indexOf(":") + a + v);
|
|
4610
4627
|
}
|
|
4611
|
-
function
|
|
4628
|
+
function Te(v) {
|
|
4612
4629
|
O(
|
|
4613
4630
|
$,
|
|
4614
4631
|
"onMessage passed: {iframe: " + R.iframe.id + ", message: " + v + "}"
|
|
@@ -4678,7 +4695,7 @@ var en = { exports: {} };
|
|
|
4678
4695
|
y: Math.floor(Number(C.top) + Number(l.y))
|
|
4679
4696
|
};
|
|
4680
4697
|
}
|
|
4681
|
-
function
|
|
4698
|
+
function T(v) {
|
|
4682
4699
|
function C() {
|
|
4683
4700
|
l = q, F(), O($, "--");
|
|
4684
4701
|
}
|
|
@@ -4750,13 +4767,13 @@ var en = { exports: {} };
|
|
|
4750
4767
|
return ps($, v, C);
|
|
4751
4768
|
}
|
|
4752
4769
|
function xs() {
|
|
4753
|
-
switch (d[$] && d[$].firstRun &&
|
|
4770
|
+
switch (d[$] && d[$].firstRun && Ss(), R.type) {
|
|
4754
4771
|
case "close": {
|
|
4755
4772
|
ms(R.iframe);
|
|
4756
4773
|
break;
|
|
4757
4774
|
}
|
|
4758
4775
|
case "message": {
|
|
4759
|
-
|
|
4776
|
+
Te(ye(6));
|
|
4760
4777
|
break;
|
|
4761
4778
|
}
|
|
4762
4779
|
case "mouseenter": {
|
|
@@ -4772,11 +4789,11 @@ var en = { exports: {} };
|
|
|
4772
4789
|
break;
|
|
4773
4790
|
}
|
|
4774
4791
|
case "scrollTo": {
|
|
4775
|
-
|
|
4792
|
+
T(!1);
|
|
4776
4793
|
break;
|
|
4777
4794
|
}
|
|
4778
4795
|
case "scrollToOffset": {
|
|
4779
|
-
|
|
4796
|
+
T(!0);
|
|
4780
4797
|
break;
|
|
4781
4798
|
}
|
|
4782
4799
|
case "pageInfo": {
|
|
@@ -4814,7 +4831,7 @@ var en = { exports: {} };
|
|
|
4814
4831
|
R.type + " No settings for " + v + ". Message was: " + se
|
|
4815
4832
|
)), C;
|
|
4816
4833
|
}
|
|
4817
|
-
function
|
|
4834
|
+
function Ts() {
|
|
4818
4835
|
for (var v in d)
|
|
4819
4836
|
ce(
|
|
4820
4837
|
"iFrame requested init",
|
|
@@ -4823,11 +4840,11 @@ var en = { exports: {} };
|
|
|
4823
4840
|
v
|
|
4824
4841
|
);
|
|
4825
4842
|
}
|
|
4826
|
-
function
|
|
4843
|
+
function Ss() {
|
|
4827
4844
|
d[$] && (d[$].firstRun = !1);
|
|
4828
4845
|
}
|
|
4829
4846
|
var se = u.data, R = {}, $ = null;
|
|
4830
|
-
se === "[iFrameResizerChild]Ready" ?
|
|
4847
|
+
se === "[iFrameResizerChild]Ready" ? Ts() : Ne() ? (R = M(), $ = R.id, d[$] && (d[$].loaded = !0), !ge() && ks($) && (O($, "Received: " + se), _s() && de() && xs())) : Ws($, "Ignored: " + se);
|
|
4831
4848
|
}
|
|
4832
4849
|
function ps(u, y, M) {
|
|
4833
4850
|
var x = null, P = null;
|
|
@@ -4911,11 +4928,11 @@ var en = { exports: {} };
|
|
|
4911
4928
|
}
|
|
4912
4929
|
function ce(u, y, M, x, P) {
|
|
4913
4930
|
function Z() {
|
|
4914
|
-
var
|
|
4931
|
+
var Te = d[x] && d[x].targetOrigin;
|
|
4915
4932
|
O(
|
|
4916
4933
|
x,
|
|
4917
|
-
"[" + u + "] Sending msg to iframe[" + x + "] (" + y + ") targetOrigin: " +
|
|
4918
|
-
), M.contentWindow.postMessage(o + y,
|
|
4934
|
+
"[" + u + "] Sending msg to iframe[" + x + "] (" + y + ") targetOrigin: " + Te
|
|
4935
|
+
), M.contentWindow.postMessage(o + y, Te);
|
|
4919
4936
|
}
|
|
4920
4937
|
function de() {
|
|
4921
4938
|
ee(x, "[" + u + "] IFrame(" + x + ") not found");
|
|
@@ -4924,14 +4941,14 @@ var en = { exports: {} };
|
|
|
4924
4941
|
M && "contentWindow" in M && M.contentWindow !== null ? Z() : de();
|
|
4925
4942
|
}
|
|
4926
4943
|
function ge() {
|
|
4927
|
-
function
|
|
4944
|
+
function Te() {
|
|
4928
4945
|
d[x] && !d[x].loaded && !ye && (ye = !0, ee(
|
|
4929
4946
|
x,
|
|
4930
4947
|
"IFrame has not responded within " + d[x].warningTimeout / 1e3 + " seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."
|
|
4931
4948
|
));
|
|
4932
4949
|
}
|
|
4933
4950
|
P && d[x] && d[x].warningTimeout && (d[x].msgTimeout = setTimeout(
|
|
4934
|
-
|
|
4951
|
+
Te,
|
|
4935
4952
|
d[x].warningTimeout
|
|
4936
4953
|
));
|
|
4937
4954
|
}
|
|
@@ -4946,7 +4963,7 @@ var en = { exports: {} };
|
|
|
4946
4963
|
}
|
|
4947
4964
|
function ti(u, y) {
|
|
4948
4965
|
function M() {
|
|
4949
|
-
function
|
|
4966
|
+
function T(W) {
|
|
4950
4967
|
var te = d[k][W];
|
|
4951
4968
|
te !== 1 / 0 && te !== 0 && (u.style[W] = ln(te) ? te + "px" : te, O(k, "Set " + W + " = " + u.style[W]));
|
|
4952
4969
|
}
|
|
@@ -4956,19 +4973,19 @@ var en = { exports: {} };
|
|
|
4956
4973
|
"Value for min" + W + " can not be greater than max" + W
|
|
4957
4974
|
);
|
|
4958
4975
|
}
|
|
4959
|
-
F("Height"), F("Width"),
|
|
4976
|
+
F("Height"), F("Width"), T("maxHeight"), T("minHeight"), T("maxWidth"), T("minWidth");
|
|
4960
4977
|
}
|
|
4961
4978
|
function x() {
|
|
4962
|
-
var
|
|
4963
|
-
return document.getElementById(
|
|
4979
|
+
var T = y && y.id || N.id + t++;
|
|
4980
|
+
return document.getElementById(T) !== null && (T += t++), T;
|
|
4964
4981
|
}
|
|
4965
|
-
function P(
|
|
4966
|
-
if (typeof
|
|
4982
|
+
function P(T) {
|
|
4983
|
+
if (typeof T != "string")
|
|
4967
4984
|
throw new TypeError("Invaild id for iFrame. Expected String");
|
|
4968
|
-
return
|
|
4969
|
-
|
|
4970
|
-
"Added missing iframe ID: " +
|
|
4971
|
-
)),
|
|
4985
|
+
return T === "" && (u.id = T = x(), i = (y || {}).log, O(
|
|
4986
|
+
T,
|
|
4987
|
+
"Added missing iframe ID: " + T + " (" + u.src + ")"
|
|
4988
|
+
)), T;
|
|
4972
4989
|
}
|
|
4973
4990
|
function Z() {
|
|
4974
4991
|
switch (O(
|
|
@@ -4993,8 +5010,8 @@ var en = { exports: {} };
|
|
|
4993
5010
|
(typeof (d[k] && d[k].bodyMargin) == "number" || (d[k] && d[k].bodyMargin) === "0") && (d[k].bodyMarginV1 = d[k].bodyMargin, d[k].bodyMargin = "" + d[k].bodyMargin + "px");
|
|
4994
5011
|
}
|
|
4995
5012
|
function Ne() {
|
|
4996
|
-
var
|
|
4997
|
-
!
|
|
5013
|
+
var T = d[k] && d[k].firstRun, F = d[k] && d[k].heightCalculationMethod in p;
|
|
5014
|
+
!T && F && Gs({ iframe: u, height: 0, width: 0, type: "init" });
|
|
4998
5015
|
}
|
|
4999
5016
|
function ge() {
|
|
5000
5017
|
d[k] && (d[k].iframe.iFrameResizer = {
|
|
@@ -5009,34 +5026,34 @@ var en = { exports: {} };
|
|
|
5009
5026
|
"resize",
|
|
5010
5027
|
d[k].iframe
|
|
5011
5028
|
),
|
|
5012
|
-
moveToAnchor: function(
|
|
5029
|
+
moveToAnchor: function(T) {
|
|
5013
5030
|
ce(
|
|
5014
5031
|
"Move to anchor",
|
|
5015
|
-
"moveToAnchor:" +
|
|
5032
|
+
"moveToAnchor:" + T,
|
|
5016
5033
|
d[k].iframe,
|
|
5017
5034
|
k
|
|
5018
5035
|
);
|
|
5019
5036
|
},
|
|
5020
|
-
sendMessage: function(
|
|
5021
|
-
|
|
5037
|
+
sendMessage: function(T) {
|
|
5038
|
+
T = JSON.stringify(T), ce(
|
|
5022
5039
|
"Send Message",
|
|
5023
|
-
"message:" +
|
|
5040
|
+
"message:" + T,
|
|
5024
5041
|
d[k].iframe,
|
|
5025
5042
|
k
|
|
5026
5043
|
);
|
|
5027
5044
|
}
|
|
5028
5045
|
});
|
|
5029
5046
|
}
|
|
5030
|
-
function ye(
|
|
5047
|
+
function ye(T) {
|
|
5031
5048
|
function F() {
|
|
5032
|
-
ce("iFrame.onload",
|
|
5049
|
+
ce("iFrame.onload", T, u, e, !0), Ne();
|
|
5033
5050
|
}
|
|
5034
5051
|
function W(Pe) {
|
|
5035
5052
|
if (u.parentNode) {
|
|
5036
5053
|
var xs = new Pe(function(ks) {
|
|
5037
|
-
ks.forEach(function(
|
|
5038
|
-
var
|
|
5039
|
-
|
|
5054
|
+
ks.forEach(function(Ts) {
|
|
5055
|
+
var Ss = Array.prototype.slice.call(Ts.removedNodes);
|
|
5056
|
+
Ss.forEach(function(se) {
|
|
5040
5057
|
se === u && ms(u);
|
|
5041
5058
|
});
|
|
5042
5059
|
});
|
|
@@ -5047,34 +5064,34 @@ var en = { exports: {} };
|
|
|
5047
5064
|
}
|
|
5048
5065
|
}
|
|
5049
5066
|
var te = U();
|
|
5050
|
-
te && W(te), G(u, "load", F), ce("init",
|
|
5067
|
+
te && W(te), G(u, "load", F), ce("init", T, u, e, !0);
|
|
5051
5068
|
}
|
|
5052
|
-
function
|
|
5053
|
-
if (typeof
|
|
5069
|
+
function Te(T) {
|
|
5070
|
+
if (typeof T != "object")
|
|
5054
5071
|
throw new TypeError("Options is not an object");
|
|
5055
5072
|
}
|
|
5056
|
-
function vs(
|
|
5073
|
+
function vs(T) {
|
|
5057
5074
|
for (var F in N)
|
|
5058
5075
|
Object.prototype.hasOwnProperty.call(N, F) && (d[k][F] = Object.prototype.hasOwnProperty.call(
|
|
5059
|
-
|
|
5076
|
+
T,
|
|
5060
5077
|
F
|
|
5061
|
-
) ?
|
|
5078
|
+
) ? T[F] : N[F]);
|
|
5062
5079
|
}
|
|
5063
|
-
function Rt(
|
|
5064
|
-
return
|
|
5080
|
+
function Rt(T) {
|
|
5081
|
+
return T === "" || T.match(/^(about:blank|javascript:|file:\/\/)/) !== null ? "*" : T;
|
|
5065
5082
|
}
|
|
5066
|
-
function bs(
|
|
5067
|
-
var F =
|
|
5083
|
+
function bs(T) {
|
|
5084
|
+
var F = T.split("Callback");
|
|
5068
5085
|
if (F.length === 2) {
|
|
5069
5086
|
var W = "on" + F[0].charAt(0).toUpperCase() + F[0].slice(1);
|
|
5070
|
-
this[W] = this[
|
|
5087
|
+
this[W] = this[T], delete this[T], ee(
|
|
5071
5088
|
k,
|
|
5072
|
-
"Deprecated: '" +
|
|
5089
|
+
"Deprecated: '" + T + "' has been renamed '" + W + "'. The old method will be removed in the next major version."
|
|
5073
5090
|
);
|
|
5074
5091
|
}
|
|
5075
5092
|
}
|
|
5076
|
-
function ws(
|
|
5077
|
-
|
|
5093
|
+
function ws(T) {
|
|
5094
|
+
T = T || {}, d[k] = /* @__PURE__ */ Object.create(null), d[k].iframe = u, d[k].firstRun = !0, d[k].remoteHost = u.src && u.src.split("/").slice(0, 3).join("/"), Te(T), Object.keys(T).forEach(bs, T), vs(T), d[k] && (d[k].targetOrigin = d[k].checkOrigin === !0 ? Rt(d[k].remoteHost) : "*");
|
|
5078
5095
|
}
|
|
5079
5096
|
function _s() {
|
|
5080
5097
|
return k in d && "iFrameResizer" in u;
|
|
@@ -5669,7 +5686,7 @@ function on(s) {
|
|
|
5669
5686
|
});
|
|
5670
5687
|
} };
|
|
5671
5688
|
}
|
|
5672
|
-
class
|
|
5689
|
+
class Ta {
|
|
5673
5690
|
constructor(e) {
|
|
5674
5691
|
this.chatWsUrl = e, this._emitter = on(), this.on = this._emitter.on.bind(this._emitter), this.off = this._emitter.off.bind(this._emitter), this.reconnectCodes = /* @__PURE__ */ new Set([
|
|
5675
5692
|
1006
|
|
@@ -5700,7 +5717,7 @@ class Sa {
|
|
|
5700
5717
|
this.disconnect(), this._emitter.all.clear();
|
|
5701
5718
|
}
|
|
5702
5719
|
}
|
|
5703
|
-
const
|
|
5720
|
+
const Sa = ns.AcknowledgeType, $a = "Anyone Home", Ea = "IB Chat Leasing - Development";
|
|
5704
5721
|
let Ca = "https://five9.ah.inhabit.work";
|
|
5705
5722
|
const Aa = "https://five9.ah.inhabit.work".replace("http", "ws").replace(/\/$/, "");
|
|
5706
5723
|
var be, ze;
|
|
@@ -5708,7 +5725,7 @@ const ft = class ft {
|
|
|
5708
5725
|
constructor() {
|
|
5709
5726
|
$s(this, be, void 0);
|
|
5710
5727
|
$s(this, ze, void 0);
|
|
5711
|
-
this._emitter = on(), this.on = this._emitter.on.bind(this._emitter), this.off = this._emitter.off.bind(this._emitter),
|
|
5728
|
+
this._emitter = on(), this.on = this._emitter.on.bind(this._emitter), this.off = this._emitter.off.bind(this._emitter), Se(this, be, null), Se(this, ze, null), this.conversationStarted = !1;
|
|
5712
5729
|
}
|
|
5713
5730
|
serialize() {
|
|
5714
5731
|
return JSON.stringify({
|
|
@@ -5733,13 +5750,13 @@ const ft = class ft {
|
|
|
5733
5750
|
},
|
|
5734
5751
|
body: JSON.stringify({ tenantName: $a })
|
|
5735
5752
|
});
|
|
5736
|
-
return
|
|
5753
|
+
return Se(this, be, await e.json()), Zt(this, be);
|
|
5737
5754
|
}
|
|
5738
5755
|
setSession(e) {
|
|
5739
|
-
|
|
5756
|
+
Se(this, be, e);
|
|
5740
5757
|
}
|
|
5741
5758
|
setConversationId(e) {
|
|
5742
|
-
|
|
5759
|
+
Se(this, ze, e), this.five9WebSocket && (this.five9WebSocket.destroy(), this.five9WebSocket = void 0, e && this.connectToWebSocket());
|
|
5743
5760
|
}
|
|
5744
5761
|
connect() {
|
|
5745
5762
|
if (!this.sessionToken)
|
|
@@ -5752,7 +5769,7 @@ const ft = class ft {
|
|
|
5752
5769
|
if (!this.conversationId)
|
|
5753
5770
|
throw new Error("Conversation not started");
|
|
5754
5771
|
this.five9WebSocket && this.five9WebSocket.destroy();
|
|
5755
|
-
const e = new
|
|
5772
|
+
const e = new Ta(`${Aa}/conversations/${this.conversationId}/ws`);
|
|
5756
5773
|
e.on("*", (t, i) => {
|
|
5757
5774
|
this._emitter.emit(t, i);
|
|
5758
5775
|
}), e.on("conversationCreated", (t) => {
|
|
@@ -5774,7 +5791,7 @@ const ft = class ft {
|
|
|
5774
5791
|
messages: [
|
|
5775
5792
|
{
|
|
5776
5793
|
messageId: t.messageId,
|
|
5777
|
-
type:
|
|
5794
|
+
type: Sa.READ
|
|
5778
5795
|
}
|
|
5779
5796
|
]
|
|
5780
5797
|
});
|
|
@@ -5863,7 +5880,7 @@ const ft = class ft {
|
|
|
5863
5880
|
}), this.destroy();
|
|
5864
5881
|
}
|
|
5865
5882
|
destroy() {
|
|
5866
|
-
this.five9WebSocket && this.five9WebSocket.destroy(),
|
|
5883
|
+
this.five9WebSocket && this.five9WebSocket.destroy(), Se(this, be, null), Se(this, ze, null);
|
|
5867
5884
|
}
|
|
5868
5885
|
// Getters
|
|
5869
5886
|
get sessionToken() {
|
|
@@ -5898,60 +5915,135 @@ let rs = ft;
|
|
|
5898
5915
|
function mt(s) {
|
|
5899
5916
|
return `any-${s || "main"}-chatSession`;
|
|
5900
5917
|
}
|
|
5901
|
-
async function Oa({
|
|
5902
|
-
|
|
5918
|
+
async function Oa({
|
|
5919
|
+
id: s,
|
|
5920
|
+
params: e,
|
|
5921
|
+
chatWindow: t,
|
|
5922
|
+
html: i
|
|
5923
|
+
}) {
|
|
5924
|
+
t = t;
|
|
5925
|
+
const n = async () => {
|
|
5926
|
+
t.removeMessage("transferMessageId"), await t.sendFunctionCallResponse(
|
|
5927
|
+
s,
|
|
5928
|
+
{
|
|
5929
|
+
transfer: "Declined"
|
|
5930
|
+
},
|
|
5931
|
+
!0
|
|
5932
|
+
), t.setInputDisabled(!1);
|
|
5933
|
+
}, r = async () => {
|
|
5934
|
+
t.setInputDisabled(!0), t.removeMessage("transferMessageId"), t.addMessage({
|
|
5935
|
+
role: "system",
|
|
5936
|
+
content: "Please wait while we connect you to a live agent"
|
|
5937
|
+
});
|
|
5938
|
+
const a = new rs();
|
|
5939
|
+
await a.createSession();
|
|
5940
|
+
const { summary: o, subject: c, ...l } = e;
|
|
5941
|
+
await a.createConversation({
|
|
5942
|
+
contact: l,
|
|
5943
|
+
attributes: {
|
|
5944
|
+
Question: c,
|
|
5945
|
+
"AI Summary": o
|
|
5946
|
+
}
|
|
5947
|
+
}), localStorage.setItem(
|
|
5948
|
+
mt(t.cleanOptions.config.historyKey),
|
|
5949
|
+
a.serialize()
|
|
5950
|
+
), cn(t, a);
|
|
5951
|
+
};
|
|
5952
|
+
t.addMessage({
|
|
5953
|
+
id: "transferMessageId",
|
|
5954
|
+
// This is a unique id for the message
|
|
5903
5955
|
role: "system",
|
|
5904
|
-
|
|
5956
|
+
contentHtmlTemplate: i`
|
|
5957
|
+
<style>
|
|
5958
|
+
.btn {
|
|
5959
|
+
background-color: #007bff;
|
|
5960
|
+
color: white;
|
|
5961
|
+
border: none;
|
|
5962
|
+
padding: 10px 20px;
|
|
5963
|
+
text-align: center;
|
|
5964
|
+
text-decoration: none;
|
|
5965
|
+
display: inline-block;
|
|
5966
|
+
font-size: 16px;
|
|
5967
|
+
margin: 4px 2px;
|
|
5968
|
+
cursor: pointer;
|
|
5969
|
+
border-radius: 5px;
|
|
5970
|
+
}
|
|
5971
|
+
|
|
5972
|
+
.btn-no {
|
|
5973
|
+
background-color: #dc3545;
|
|
5974
|
+
}
|
|
5975
|
+
</style>
|
|
5976
|
+
<div class="my-4">
|
|
5977
|
+
<strong>Would you like to transfer to an agent?</strong>
|
|
5978
|
+
<div>
|
|
5979
|
+
<button class="btn" @click=${r}>Yes</button>
|
|
5980
|
+
<button class="btn btn-no" @click=${n}>No</button>
|
|
5981
|
+
</div>
|
|
5982
|
+
</div>
|
|
5983
|
+
`
|
|
5905
5984
|
});
|
|
5906
|
-
const t = new rs();
|
|
5907
|
-
await t.createSession();
|
|
5908
|
-
const { summary: i, subject: n, ...r } = s;
|
|
5909
|
-
await t.createConversation({
|
|
5910
|
-
contact: r,
|
|
5911
|
-
attributes: {
|
|
5912
|
-
Question: n,
|
|
5913
|
-
"AI Summary": i
|
|
5914
|
-
}
|
|
5915
|
-
}), localStorage.setItem(mt(e.cleanOptions.config.historyKey), t.serialize()), cn(e, t);
|
|
5916
5985
|
}
|
|
5917
5986
|
function cn(s, e) {
|
|
5918
5987
|
e.on("*", (r, a) => {
|
|
5919
5988
|
console.log("event:", r, a);
|
|
5920
5989
|
}), e.on("conversationCreated", () => {
|
|
5921
|
-
s.setInputDisabled(!1), localStorage.setItem(
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5990
|
+
s.setInputDisabled(!1), localStorage.setItem(
|
|
5991
|
+
mt(s.cleanOptions.config.historyKey),
|
|
5992
|
+
e.serialize()
|
|
5993
|
+
);
|
|
5994
|
+
}), e.on(
|
|
5995
|
+
"conversationAccepted",
|
|
5996
|
+
(r) => {
|
|
5997
|
+
s.addMessage({
|
|
5998
|
+
role: "system",
|
|
5999
|
+
content: `${r.displayName} has joined the chat`
|
|
6000
|
+
});
|
|
6001
|
+
}
|
|
6002
|
+
), e.on("agentTyping", () => {
|
|
5928
6003
|
s.setTypingIndicatorVisible(!0);
|
|
5929
|
-
}), e.on(
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
6004
|
+
}), e.on(
|
|
6005
|
+
"agentJoined",
|
|
6006
|
+
(r) => {
|
|
6007
|
+
s.addMessage({
|
|
6008
|
+
role: "system",
|
|
6009
|
+
content: `${r.displayName} has joined the chat`
|
|
6010
|
+
});
|
|
6011
|
+
}
|
|
6012
|
+
), e.on(
|
|
6013
|
+
"agentTransferredConversation",
|
|
6014
|
+
(r) => {
|
|
6015
|
+
s.addMessage({
|
|
6016
|
+
role: "system",
|
|
6017
|
+
content: `You have been transferred to ${r.toDisplayName}`
|
|
6018
|
+
});
|
|
6019
|
+
}
|
|
6020
|
+
), e.on(
|
|
6021
|
+
"conversationTransferredToGroup",
|
|
6022
|
+
(r) => {
|
|
6023
|
+
s.addMessage({
|
|
6024
|
+
role: "system",
|
|
6025
|
+
content: `You have been transferred to ${r.groupName}`
|
|
6026
|
+
});
|
|
6027
|
+
}
|
|
6028
|
+
), e.on(
|
|
6029
|
+
"agentLeftConversation",
|
|
6030
|
+
(r) => {
|
|
6031
|
+
s.addMessage({
|
|
6032
|
+
role: "system",
|
|
6033
|
+
content: `${r.displayName} has left the chat`
|
|
6034
|
+
});
|
|
6035
|
+
}
|
|
6036
|
+
), e.on(
|
|
6037
|
+
"conversationTerminated",
|
|
6038
|
+
(r) => {
|
|
6039
|
+
s.addMessage({
|
|
6040
|
+
role: "system",
|
|
6041
|
+
content: "The chat has ended"
|
|
6042
|
+
}), s.setInputDisabled(!0), localStorage.removeItem(
|
|
6043
|
+
mt(s.cleanOptions.config.historyKey)
|
|
6044
|
+
);
|
|
6045
|
+
}
|
|
6046
|
+
), e.on("message", (r) => {
|
|
5955
6047
|
switch (r.from) {
|
|
5956
6048
|
case "SYSTEM":
|
|
5957
6049
|
s.addMessage({
|
|
@@ -5977,11 +6069,22 @@ function cn(s, e) {
|
|
|
5977
6069
|
content: r.detail.message
|
|
5978
6070
|
}), await e.sendMessage(r.detail.message);
|
|
5979
6071
|
}, i = async () => {
|
|
5980
|
-
console.log("destroyed fired"), e.destroy(), s.removeEventListener(
|
|
6072
|
+
console.log("destroyed fired"), e.destroy(), s.removeEventListener(
|
|
6073
|
+
"iai-chat-send-user-message",
|
|
6074
|
+
t
|
|
6075
|
+
), s.removeEventListener("iai-chat-reset", n), s.removeEventListener(
|
|
6076
|
+
"iai-chat-destroy",
|
|
6077
|
+
i
|
|
6078
|
+
);
|
|
5981
6079
|
}, n = async () => {
|
|
5982
|
-
console.log("reset fired"), await e.terminateConversation(), await i(), localStorage.removeItem(
|
|
6080
|
+
console.log("reset fired"), await e.terminateConversation(), await i(), localStorage.removeItem(
|
|
6081
|
+
mt(s.cleanOptions.config.historyKey)
|
|
6082
|
+
);
|
|
5983
6083
|
};
|
|
5984
|
-
s.addEventListener(
|
|
6084
|
+
s.addEventListener(
|
|
6085
|
+
"iai-chat-send-user-message",
|
|
6086
|
+
t
|
|
6087
|
+
), s.addEventListener("iai-chat-reset", n), s.addEventListener("iai-chat-destroy", i);
|
|
5985
6088
|
}
|
|
5986
6089
|
function Ia(s) {
|
|
5987
6090
|
return async function({ id: t, params: i, chatWindow: n }) {
|