@telia-ace/widget-conversation 1.0.34-experimental.2 → 1.0.34-experimental.21
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/components/conversation/conversation-wrapper.d.ts +8 -0
- package/dist/components/conversation/conversation.d.ts +25 -6
- package/dist/components/conversation/plugin.d.ts +2 -3
- package/dist/components/conversation/ui/conversation-content.d.ts +8 -0
- package/dist/components/conversation/ui/conversation-input.d.ts +12 -0
- package/dist/components/conversation/ui/conversation-message.d.ts +16 -0
- package/dist/components/conversation/ui/message.d.ts +13 -5
- package/dist/conversation-controller.d.ts +2 -2
- package/dist/conversation-wrapper.bfcf4c5c.js +475 -0
- package/dist/conversation-wrapper.bfcf4c5c.js.map +1 -0
- package/dist/index.js +276 -312
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +14 -10
- package/dist/conversation.bc31361a.js +0 -1189
- package/dist/conversation.bc31361a.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,97 +1,88 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var K = Object.defineProperty, F = Object.defineProperties;
|
|
2
|
+
var j = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var S = Object.getOwnPropertySymbols;
|
|
4
|
+
var _ = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var O = (r, e, t) => e in r ? K(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
7
|
+
_.call(e, t) && O(r, t, e[t]);
|
|
8
|
+
if (S)
|
|
9
|
+
for (var t of S(e))
|
|
10
|
+
B.call(e, t) && O(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, g = (r, e) => F(r, j(e));
|
|
13
|
+
var M = (r, e) => {
|
|
14
14
|
var t = {};
|
|
15
15
|
for (var s in r)
|
|
16
|
-
|
|
17
|
-
if (r != null &&
|
|
18
|
-
for (var s of
|
|
19
|
-
e.indexOf(s) < 0 &&
|
|
16
|
+
_.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
|
|
17
|
+
if (r != null && S)
|
|
18
|
+
for (var s of S(r))
|
|
19
|
+
e.indexOf(s) < 0 && B.call(r, s) && (t[s] = r[s]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var i = (c) => {
|
|
22
|
+
var u = (r, e, t) => new Promise((s, i) => {
|
|
23
|
+
var n = (c) => {
|
|
25
24
|
try {
|
|
26
25
|
o(t.next(c));
|
|
27
|
-
} catch (
|
|
28
|
-
|
|
26
|
+
} catch (d) {
|
|
27
|
+
i(d);
|
|
29
28
|
}
|
|
30
29
|
}, a = (c) => {
|
|
31
30
|
try {
|
|
32
31
|
o(t.throw(c));
|
|
33
|
-
} catch (
|
|
34
|
-
|
|
32
|
+
} catch (d) {
|
|
33
|
+
i(d);
|
|
35
34
|
}
|
|
36
|
-
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(
|
|
35
|
+
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, a);
|
|
37
36
|
o((t = t.apply(r, e)).next());
|
|
38
37
|
});
|
|
39
|
-
import { ComponentPlatform as
|
|
40
|
-
import { createStorageWriter as
|
|
41
|
-
import { uuid as L, lock as
|
|
42
|
-
import { FormBuilder as
|
|
43
|
-
import { closeAllModals as
|
|
44
|
-
import { createReactComponent as
|
|
38
|
+
import { ComponentPlatform as Q } from "@telia-ace/widget-core";
|
|
39
|
+
import { createStorageWriter as x, StorageCategory as W, readStorage as y, StorageMedium as b, StorageScope as G } from "@telia-ace/widget-services";
|
|
40
|
+
import { uuid as L, lock as J } from "@telia-ace/widget-utilities";
|
|
41
|
+
import { FormBuilder as V } from "@telia-ace/widget-forms";
|
|
42
|
+
import { closeAllModals as $ } from "@telia-ace/widget-plugins";
|
|
43
|
+
import { createWebComponent as Y, createReactComponent as X } from "@telia-ace/widget-ui";
|
|
45
44
|
import { lazy as Z } from "react";
|
|
46
|
-
class
|
|
45
|
+
class I {
|
|
47
46
|
constructor(e, t) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
d(this, "avatar");
|
|
51
|
-
d(this, "print", (e, t) => {
|
|
52
|
-
const s = {
|
|
47
|
+
this.provider = e, this.print = (s, i) => {
|
|
48
|
+
const n = {
|
|
53
49
|
name: this.name,
|
|
54
50
|
avatar: this.avatar,
|
|
55
51
|
id: this.id
|
|
56
|
-
},
|
|
52
|
+
}, a = R(s, i);
|
|
57
53
|
return this.provider.createEntry(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
a.key,
|
|
55
|
+
a.content,
|
|
56
|
+
C.Agent,
|
|
57
|
+
n,
|
|
58
|
+
a.timestamp
|
|
63
59
|
);
|
|
64
|
-
});
|
|
65
|
-
d(this, "typing", () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }));
|
|
66
|
-
this.provider = e, this.id = t.id || L(), this.name = t.name, this.avatar = t.avatar;
|
|
60
|
+
}, this.typing = () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }), this.id = t.id || L(), this.name = t.name, this.avatar = t.avatar;
|
|
67
61
|
}
|
|
68
62
|
update(e) {
|
|
69
|
-
var
|
|
63
|
+
var i;
|
|
70
64
|
const { name: t, avatar: s } = e;
|
|
71
|
-
s === null ? this.avatar = void 0 : s && (this.avatar = s), t === null ? this.name = void 0 : t && (this.name = t), (
|
|
65
|
+
s === null ? this.avatar = void 0 : s && (this.avatar = s), t === null ? this.name = void 0 : t && (this.name = t), (i = this.provider.controller) == null || i.events.dispatch("conversation:agent-updated", {
|
|
72
66
|
agent: this
|
|
73
67
|
});
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
|
-
class
|
|
70
|
+
class N {
|
|
77
71
|
constructor(e, t, s) {
|
|
78
|
-
|
|
79
|
-
d(this, "options");
|
|
80
|
-
d(this, "user");
|
|
81
|
-
this.name = e, this.container = t, this.controller = s, this.user = s == null ? void 0 : s.user, this.options = {
|
|
72
|
+
this.name = e, this.container = t, this.controller = s, this.subscriptions = [], this.user = s == null ? void 0 : s.user, this.options = {
|
|
82
73
|
silent: !1
|
|
83
74
|
};
|
|
84
75
|
}
|
|
85
76
|
static create(e, t, s) {
|
|
86
|
-
return new
|
|
77
|
+
return new N(e, t, s);
|
|
87
78
|
}
|
|
88
79
|
createAgent(e = {}) {
|
|
89
80
|
var t;
|
|
90
81
|
if (this.controller) {
|
|
91
|
-
const s = this.controller.getAgentById(e.id),
|
|
82
|
+
const s = this.controller.getAgentById(e.id), i = s ? new I(this, p(p({}, s), e)) : new I(this, e);
|
|
92
83
|
return s || (t = this.controller) == null || t.events.dispatch("conversation:agent-created", {
|
|
93
|
-
agent:
|
|
94
|
-
}),
|
|
84
|
+
agent: i
|
|
85
|
+
}), i;
|
|
95
86
|
}
|
|
96
87
|
}
|
|
97
88
|
print(e) {
|
|
@@ -106,9 +97,9 @@ class T {
|
|
|
106
97
|
return this.controller ? this.controller.loader() : () => () => {
|
|
107
98
|
};
|
|
108
99
|
}
|
|
109
|
-
createEntry(e, t, s,
|
|
100
|
+
createEntry(e, t, s, i, n) {
|
|
110
101
|
var a;
|
|
111
|
-
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s,
|
|
102
|
+
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, i, n);
|
|
112
103
|
}
|
|
113
104
|
dispose() {
|
|
114
105
|
var e;
|
|
@@ -147,11 +138,10 @@ class T {
|
|
|
147
138
|
}
|
|
148
139
|
}
|
|
149
140
|
}
|
|
150
|
-
const
|
|
141
|
+
const U = (r) => `conversation-${r}`;
|
|
151
142
|
class ee {
|
|
152
143
|
constructor() {
|
|
153
|
-
|
|
154
|
-
d(this, "_locks", 0);
|
|
144
|
+
this._locking = Promise.resolve(), this._locks = 0;
|
|
155
145
|
}
|
|
156
146
|
isLocked() {
|
|
157
147
|
return this._locks > 0;
|
|
@@ -159,8 +149,8 @@ class ee {
|
|
|
159
149
|
lock() {
|
|
160
150
|
this._locks += 1;
|
|
161
151
|
let e, t = new Promise(
|
|
162
|
-
(
|
|
163
|
-
this._locks -= 1,
|
|
152
|
+
(i) => e = () => {
|
|
153
|
+
this._locks -= 1, i();
|
|
164
154
|
}
|
|
165
155
|
), s = this._locking.then(() => e);
|
|
166
156
|
return this._locking = this._locking.then(() => t), s;
|
|
@@ -168,24 +158,21 @@ class ee {
|
|
|
168
158
|
}
|
|
169
159
|
class te {
|
|
170
160
|
constructor(e, t, s) {
|
|
171
|
-
|
|
172
|
-
d(this, "locker", new ee());
|
|
173
|
-
d(this, "initialStoredAgents", []);
|
|
174
|
-
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey = q(t.id), t.onStarted(() => v(this, null, function* () {
|
|
161
|
+
this.container = e, this.conversation = t, this.enabled = s, this.locker = new ee(), this.initialStoredAgents = [], this.sessionStorageKey = U(t.id), t.onStarted(() => u(this, null, function* () {
|
|
175
162
|
if (t.messages.length > 0)
|
|
176
163
|
return;
|
|
177
|
-
const { agents:
|
|
178
|
-
|
|
179
|
-
const c = t.providerIndex(o.providerName),
|
|
180
|
-
|
|
164
|
+
const { agents: i } = yield this.read(), n = [];
|
|
165
|
+
i && i.forEach((o) => {
|
|
166
|
+
const c = t.providerIndex(o.providerName), d = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), l = new I(d, { name: o.name, avatar: o.avatar, id: o.id });
|
|
167
|
+
n.push(l);
|
|
181
168
|
});
|
|
182
169
|
const { messages: a } = yield this.read();
|
|
183
170
|
a.forEach((o) => {
|
|
184
171
|
switch (o.type) {
|
|
185
172
|
case "agent": {
|
|
186
|
-
const c =
|
|
187
|
-
var
|
|
188
|
-
return
|
|
173
|
+
const c = n.find((d) => {
|
|
174
|
+
var l;
|
|
175
|
+
return d.id === ((l = o.sender) == null ? void 0 : l.id);
|
|
189
176
|
});
|
|
190
177
|
c && c.print(o.content.items || o.content, {
|
|
191
178
|
key: o.key
|
|
@@ -203,23 +190,23 @@ class te {
|
|
|
203
190
|
t.print(o.content.items || o.content);
|
|
204
191
|
}
|
|
205
192
|
});
|
|
206
|
-
})), t.onMessageCreated((
|
|
207
|
-
this.write(
|
|
208
|
-
})), t.events.subscribe("conversation:agent-created", (
|
|
193
|
+
})), t.onMessageCreated((i, n) => u(this, null, function* () {
|
|
194
|
+
this.write(n.message, "messages");
|
|
195
|
+
})), t.events.subscribe("conversation:agent-created", (i, n) => u(this, null, function* () {
|
|
209
196
|
const a = {
|
|
210
|
-
id:
|
|
211
|
-
name:
|
|
212
|
-
avatar:
|
|
213
|
-
providerName:
|
|
197
|
+
id: n.agent.id,
|
|
198
|
+
name: n.agent.name,
|
|
199
|
+
avatar: n.agent.avatar,
|
|
200
|
+
providerName: n.agent.provider.name
|
|
214
201
|
};
|
|
215
202
|
yield this.write(a, "agents");
|
|
216
|
-
})), t.events.subscribe("conversation:agent-updated", (
|
|
203
|
+
})), t.events.subscribe("conversation:agent-updated", (i, n) => u(this, null, function* () {
|
|
217
204
|
const { agents: a } = yield this.read();
|
|
218
205
|
yield this.write(
|
|
219
206
|
[
|
|
220
|
-
...a.map((o) => o.id ===
|
|
221
|
-
name:
|
|
222
|
-
avatar:
|
|
207
|
+
...a.map((o) => o.id === n.agent.id ? g(p({}, o), {
|
|
208
|
+
name: n.agent.name,
|
|
209
|
+
avatar: n.agent.avatar
|
|
223
210
|
}) : o)
|
|
224
211
|
],
|
|
225
212
|
"agents",
|
|
@@ -231,7 +218,7 @@ class te {
|
|
|
231
218
|
this.initialStoredAgents = e.agents;
|
|
232
219
|
}
|
|
233
220
|
isRehydrated() {
|
|
234
|
-
return
|
|
221
|
+
return u(this, null, function* () {
|
|
235
222
|
const { messages: e } = yield this.read();
|
|
236
223
|
return e.length > 0;
|
|
237
224
|
});
|
|
@@ -241,43 +228,43 @@ class te {
|
|
|
241
228
|
return this.initialStoredAgents.find((t) => t.id === e);
|
|
242
229
|
}
|
|
243
230
|
write(e, t, s = "add") {
|
|
244
|
-
return
|
|
231
|
+
return u(this, null, function* () {
|
|
245
232
|
if (!this.enabled)
|
|
246
233
|
return;
|
|
247
|
-
const
|
|
248
|
-
return
|
|
234
|
+
const i = yield this.locker.lock();
|
|
235
|
+
return x(
|
|
249
236
|
this.container,
|
|
250
237
|
this.sessionStorageKey,
|
|
251
|
-
|
|
252
|
-
).then((
|
|
238
|
+
W.Necessary
|
|
239
|
+
).then((n) => u(this, null, function* () {
|
|
253
240
|
if (s === "add") {
|
|
254
241
|
const a = yield this.read();
|
|
255
242
|
if (t === "messages" && a.messages.findIndex((c) => c.key === e.key) > -1) {
|
|
256
|
-
|
|
243
|
+
i();
|
|
257
244
|
return;
|
|
258
245
|
}
|
|
259
|
-
let o =
|
|
260
|
-
return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]),
|
|
261
|
-
|
|
246
|
+
let o = p({}, a);
|
|
247
|
+
return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]), n(p(p({}, a), o)).then(() => {
|
|
248
|
+
i();
|
|
262
249
|
});
|
|
263
250
|
}
|
|
264
251
|
if (s === "update" && t === "agents") {
|
|
265
252
|
const a = yield this.read();
|
|
266
|
-
return
|
|
253
|
+
return n(g(p({}, a), {
|
|
267
254
|
agents: e
|
|
268
255
|
})).then(() => {
|
|
269
|
-
|
|
256
|
+
i();
|
|
270
257
|
});
|
|
271
258
|
}
|
|
272
|
-
return
|
|
273
|
-
|
|
259
|
+
return n(e).then(() => {
|
|
260
|
+
i();
|
|
274
261
|
});
|
|
275
262
|
}));
|
|
276
263
|
});
|
|
277
264
|
}
|
|
278
265
|
read() {
|
|
279
|
-
return
|
|
280
|
-
return
|
|
266
|
+
return u(this, null, function* () {
|
|
267
|
+
return y(this.container, this.sessionStorageKey).then((e) => e || {
|
|
281
268
|
messages: [],
|
|
282
269
|
agents: []
|
|
283
270
|
});
|
|
@@ -287,28 +274,27 @@ class te {
|
|
|
287
274
|
const se = te;
|
|
288
275
|
class re {
|
|
289
276
|
constructor(e) {
|
|
290
|
-
|
|
291
|
-
const
|
|
277
|
+
this.controller = e, this.print = (t, s) => {
|
|
278
|
+
const i = R(t, s);
|
|
292
279
|
return this.controller.createEntry(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
280
|
+
i.key,
|
|
281
|
+
i.content,
|
|
282
|
+
C.User,
|
|
296
283
|
void 0,
|
|
297
|
-
|
|
284
|
+
i.timestamp
|
|
298
285
|
);
|
|
299
|
-
}
|
|
300
|
-
this.controller = e;
|
|
286
|
+
};
|
|
301
287
|
}
|
|
302
288
|
}
|
|
303
|
-
const
|
|
304
|
-
const s = yield r.getAsync("conversation"),
|
|
305
|
-
if (
|
|
306
|
-
const a = [...
|
|
289
|
+
const E = (r, e, t) => u(void 0, null, function* () {
|
|
290
|
+
const s = yield r.getAsync("conversation"), i = yield r.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
|
|
291
|
+
if (n) {
|
|
292
|
+
const a = [...n.conversation.providers];
|
|
307
293
|
a.forEach((c) => {
|
|
308
|
-
|
|
309
|
-
}),
|
|
310
|
-
const o =
|
|
311
|
-
|
|
294
|
+
n.conversation.setProviderOptions(c, { silent: !0 });
|
|
295
|
+
}), n.conversation.queueProviders(a), n.conversation.setProviders([t]);
|
|
296
|
+
const o = i.components().ofType("conversation");
|
|
297
|
+
i.write({
|
|
312
298
|
key: "setConversationProvider",
|
|
313
299
|
attributes: {
|
|
314
300
|
properties: { providers: [t] }
|
|
@@ -318,7 +304,7 @@ const W = (r, e, t) => v(void 0, null, function* () {
|
|
|
318
304
|
});
|
|
319
305
|
}
|
|
320
306
|
});
|
|
321
|
-
class
|
|
307
|
+
class ie {
|
|
322
308
|
constructor(e) {
|
|
323
309
|
this.writer = e;
|
|
324
310
|
}
|
|
@@ -333,81 +319,68 @@ class ne {
|
|
|
333
319
|
return typeof e == "string" ? { body: e } : e.length > -1 && typeof e == "object" ? { items: e } : e;
|
|
334
320
|
}
|
|
335
321
|
}
|
|
336
|
-
var
|
|
337
|
-
const
|
|
338
|
-
let t, s = (e == null ? void 0 : e.key) || L(),
|
|
322
|
+
var C = /* @__PURE__ */ ((r) => (r.User = "user", r.Agent = "agent", r.System = "system", r))(C || {});
|
|
323
|
+
const R = (r, e) => {
|
|
324
|
+
let t, s = (e == null ? void 0 : e.key) || L(), i = Date.now();
|
|
339
325
|
if (Array.isArray(r) && r.length > -1)
|
|
340
326
|
typeof r[0] == "string" ? t = { items: [r] } : t = { items: r };
|
|
341
327
|
else if (typeof r == "string")
|
|
342
328
|
t = { body: r };
|
|
343
329
|
else if (r = r || {}, r.type)
|
|
344
|
-
t =
|
|
330
|
+
t = p({}, r);
|
|
345
331
|
else {
|
|
346
332
|
if (t = {
|
|
347
333
|
body: r.body,
|
|
348
334
|
actions: r.actions,
|
|
349
335
|
title: r.title
|
|
350
|
-
}, r.key && (s = r.key), r.timestamp && (
|
|
351
|
-
const
|
|
352
|
-
r.form(
|
|
353
|
-
const a =
|
|
336
|
+
}, r.key && (s = r.key), r.timestamp && (i = r.timestamp), typeof r.form == "function") {
|
|
337
|
+
const n = V.create(s);
|
|
338
|
+
r.form(n);
|
|
339
|
+
const a = n.get();
|
|
354
340
|
t.form = a;
|
|
355
341
|
}
|
|
356
|
-
r.timestamp === null && (
|
|
342
|
+
r.timestamp === null && (i = null);
|
|
357
343
|
}
|
|
358
|
-
return { content: t, key: s, timestamp:
|
|
359
|
-
},
|
|
344
|
+
return { content: t, key: s, timestamp: i };
|
|
345
|
+
}, z = (r, e) => {
|
|
360
346
|
if (!e)
|
|
361
347
|
return;
|
|
362
|
-
const t = JSON.stringify(e), s = r.findIndex((
|
|
348
|
+
const t = JSON.stringify(e), s = r.findIndex((i) => t === JSON.stringify(i));
|
|
363
349
|
if (s > -1)
|
|
364
350
|
return r.splice(s, 1);
|
|
365
351
|
};
|
|
366
|
-
class
|
|
352
|
+
class ne {
|
|
367
353
|
constructor(e, t, s) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
d(this, "events");
|
|
371
|
-
d(this, "providers", []);
|
|
372
|
-
d(this, "active", !1);
|
|
373
|
-
d(this, "queuedProviders", []);
|
|
374
|
-
d(this, "registeredProviders", []);
|
|
375
|
-
d(this, "loaders", 0);
|
|
376
|
-
d(this, "componentMounted", !1);
|
|
377
|
-
d(this, "store");
|
|
378
|
-
d(this, "messages", []);
|
|
379
|
-
d(this, "typingActors", []);
|
|
380
|
-
d(this, "print", (e) => {
|
|
381
|
-
const t = D(e);
|
|
354
|
+
this.container = e, this.id = t, this.formHandlers = {}, this.user = new re(this), this.providers = [], this.active = !1, this.queuedProviders = [], this.registeredProviders = [], this.loaders = 0, this.componentMounted = !1, this.messages = [], this.typingActors = [], this.print = (n) => {
|
|
355
|
+
const a = R(n);
|
|
382
356
|
return this.createEntry(
|
|
383
|
-
|
|
384
|
-
|
|
357
|
+
a.key,
|
|
358
|
+
a.content,
|
|
385
359
|
"system",
|
|
386
360
|
void 0,
|
|
387
|
-
|
|
361
|
+
a.timestamp
|
|
388
362
|
);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
this.events = n.events.createChild(this), this.store = new se(e, this, s.rehydrate);
|
|
363
|
+
};
|
|
364
|
+
const i = e.get("$widget");
|
|
365
|
+
this.events = i.events.createChild(this), this.store = new se(e, this, s.rehydrate);
|
|
393
366
|
}
|
|
394
367
|
setInitialStorage(e) {
|
|
395
368
|
this.store.setInitialData(e);
|
|
396
369
|
}
|
|
397
370
|
setProviders(e) {
|
|
398
371
|
const t = [], s = [];
|
|
399
|
-
this.providers.reduce((
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
}), e.forEach((
|
|
403
|
-
this.providers.indexOf(
|
|
372
|
+
this.providers.reduce((i, n) => (e.indexOf(n) === -1 && i.push(n), i), []).forEach((i) => {
|
|
373
|
+
const n = this.providers.indexOf(i);
|
|
374
|
+
n > -1 && (t.push(i), this.providers.splice(n, 1));
|
|
375
|
+
}), e.forEach((i) => {
|
|
376
|
+
this.providers.indexOf(i) === -1 && (s.push(i), this.providers.push(i));
|
|
404
377
|
}), (s.length || t.length) && this.events.dispatch("conversation:providers-changed", { added: s, removed: t });
|
|
405
378
|
}
|
|
406
379
|
createProvider(e) {
|
|
407
380
|
const t = this.providerIndex(e);
|
|
408
381
|
if (t > -1)
|
|
409
382
|
return this.registeredProviders[t];
|
|
410
|
-
const s =
|
|
383
|
+
const s = N.create(e, this.container, this);
|
|
411
384
|
return this.registeredProviders.push(s), s;
|
|
412
385
|
}
|
|
413
386
|
providerIndex(e) {
|
|
@@ -447,14 +420,14 @@ class ie {
|
|
|
447
420
|
s > -1 && this.registeredProviders[s].setOptions(t);
|
|
448
421
|
}
|
|
449
422
|
changeProvider(e) {
|
|
450
|
-
this.registeredProviders.find((s) => s.name === e) &&
|
|
423
|
+
this.registeredProviders.find((s) => s.name === e) && E(this.container, this.id, e);
|
|
451
424
|
}
|
|
452
425
|
queueProviders(e) {
|
|
453
426
|
this.queuedProviders = e;
|
|
454
427
|
}
|
|
455
428
|
onCompleteProvider() {
|
|
456
429
|
const e = this.queuedProviders.pop();
|
|
457
|
-
e &&
|
|
430
|
+
e && E(this.container, this.id, e);
|
|
458
431
|
}
|
|
459
432
|
getComponentMountedState() {
|
|
460
433
|
return this.componentMounted;
|
|
@@ -462,22 +435,22 @@ class ie {
|
|
|
462
435
|
onUnreadMessage(e) {
|
|
463
436
|
return this.events.subscribe("conversation:unread-message", e);
|
|
464
437
|
}
|
|
465
|
-
createEntry(e, t, s,
|
|
438
|
+
createEntry(e, t, s, i, n) {
|
|
466
439
|
const a = {
|
|
467
440
|
key: e,
|
|
468
441
|
content: t,
|
|
469
442
|
type: s,
|
|
470
|
-
sender:
|
|
471
|
-
timestamp:
|
|
443
|
+
sender: i || null,
|
|
444
|
+
timestamp: n || n === null ? n : Date.now()
|
|
472
445
|
};
|
|
473
|
-
this.messages.push(a), a.type === "agent" &&
|
|
474
|
-
const o = new
|
|
446
|
+
this.messages.push(a), a.type === "agent" && z(this.typingActors, i);
|
|
447
|
+
const o = new ie((c) => {
|
|
475
448
|
if (c !== null) {
|
|
476
|
-
const
|
|
477
|
-
a.content =
|
|
449
|
+
const d = c, { timestamp: l = void 0 } = d, m = M(d, ["timestamp"]);
|
|
450
|
+
a.content = m, l && (a.timestamp = l);
|
|
478
451
|
} else {
|
|
479
|
-
const
|
|
480
|
-
a.content = null,
|
|
452
|
+
const l = this.messages.indexOf(a);
|
|
453
|
+
a.content = null, l > -1 && this.messages.splice(l, 1);
|
|
481
454
|
}
|
|
482
455
|
this.events.dispatch("conversation:message-updated", { message: a }), this.update();
|
|
483
456
|
});
|
|
@@ -499,7 +472,7 @@ class ie {
|
|
|
499
472
|
}
|
|
500
473
|
setTypingState(e, t) {
|
|
501
474
|
return this.typingActors.indexOf(e) === -1 && (this.typingActors.push(e), this.update()), () => {
|
|
502
|
-
|
|
475
|
+
z(this.typingActors, e), this.update();
|
|
503
476
|
};
|
|
504
477
|
}
|
|
505
478
|
loader() {
|
|
@@ -510,34 +483,34 @@ class ie {
|
|
|
510
483
|
};
|
|
511
484
|
}
|
|
512
485
|
submitForm(e, t) {
|
|
513
|
-
this.formHandlers[e] =
|
|
486
|
+
this.formHandlers[e] = g(p({}, this.formHandlers[e]), { submit: t });
|
|
514
487
|
}
|
|
515
488
|
validateForm(e, t) {
|
|
516
|
-
this.formHandlers[e] =
|
|
489
|
+
this.formHandlers[e] = g(p({}, this.formHandlers[e]), { validate: t });
|
|
517
490
|
}
|
|
518
491
|
}
|
|
519
492
|
const oe = (r, e) => {
|
|
520
493
|
const t = r.split("_contact");
|
|
521
494
|
return e.widgets.get(t[0]);
|
|
522
|
-
},
|
|
523
|
-
const e = r.get("$widget"), { name: t, implementation: s } = r.get("$widget"),
|
|
524
|
-
return c && !a ? { chatWidget: c, mainWidget:
|
|
495
|
+
}, T = (r) => {
|
|
496
|
+
const e = r.get("$widget"), { name: t, implementation: s } = r.get("$widget"), i = t.indexOf("_contact") > -1 ? oe(t, s) : e, { data: n } = r.get("$settings"), { trigger: a } = i.container.get("$settings"), o = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(o);
|
|
497
|
+
return c && !a ? { chatWidget: c, mainWidget: i, data: n } : { mainWidget: i, data: n };
|
|
525
498
|
}, ae = (r) => {
|
|
526
|
-
const { chatWidget: e } =
|
|
499
|
+
const { chatWidget: e } = T(r);
|
|
527
500
|
return !!e;
|
|
528
|
-
},
|
|
529
|
-
const { mainWidget: s, data:
|
|
530
|
-
return
|
|
531
|
-
|
|
532
|
-
a.navigateToConversationIfActive(e.id).then(() =>
|
|
501
|
+
}, H = (r, e, t) => {
|
|
502
|
+
const { mainWidget: s, data: i, chatWidget: n } = T(r);
|
|
503
|
+
return n ? n.state === "activated" ? n.invoke("open").then(() => {
|
|
504
|
+
n.container.getAsync("conversation").then((a) => {
|
|
505
|
+
a.navigateToConversationIfActive(e.id).then(() => $(r));
|
|
533
506
|
});
|
|
534
|
-
}) :
|
|
535
|
-
const { trigger: a } =
|
|
536
|
-
return a.action = "hide",
|
|
537
|
-
data:
|
|
507
|
+
}) : n.activate().then(() => {
|
|
508
|
+
const { trigger: a } = n.container.get("$settings");
|
|
509
|
+
return a.action = "hide", n.invoke("setSettings", () => ({
|
|
510
|
+
data: i,
|
|
538
511
|
trigger: a,
|
|
539
512
|
activate: !0
|
|
540
|
-
})).then(() =>
|
|
513
|
+
})).then(() => n.container.getAsync("components").then((o) => {
|
|
541
514
|
const c = o.components().ofType("contact-method");
|
|
542
515
|
o.write({
|
|
543
516
|
key: "setContactMethodId",
|
|
@@ -550,45 +523,45 @@ const oe = (r, e) => {
|
|
|
550
523
|
target: c,
|
|
551
524
|
provider: "localStorage"
|
|
552
525
|
});
|
|
553
|
-
const
|
|
526
|
+
const d = o.components().ofType("conversation");
|
|
554
527
|
o.write({
|
|
555
528
|
key: "setConversationProvider",
|
|
556
529
|
attributes: {
|
|
557
530
|
properties: { providers: [e.clientName] }
|
|
558
531
|
},
|
|
559
|
-
target:
|
|
532
|
+
target: d,
|
|
560
533
|
provider: "localStorage"
|
|
561
534
|
});
|
|
562
535
|
}));
|
|
563
|
-
}).then(() =>
|
|
536
|
+
}).then(() => n.invoke("attach", {
|
|
564
537
|
key: "contact-method",
|
|
565
538
|
triggerDOMElement: t,
|
|
566
539
|
withRenderState: "open"
|
|
567
|
-
})).then(() => (
|
|
568
|
-
|
|
540
|
+
})).then(() => (x(
|
|
541
|
+
n.container,
|
|
569
542
|
"activeStickyWidget",
|
|
570
|
-
|
|
543
|
+
W.Necessary,
|
|
571
544
|
{
|
|
572
|
-
medium:
|
|
573
|
-
scope:
|
|
545
|
+
medium: b.Local,
|
|
546
|
+
scope: G.Implementation
|
|
574
547
|
}
|
|
575
|
-
).then((a) => a(
|
|
576
|
-
a.setConversationEndedBehavior(
|
|
577
|
-
}).then(() =>
|
|
548
|
+
).then((a) => a(n.name)), n.container.getAsync("conversation").then((a) => {
|
|
549
|
+
a.setConversationEndedBehavior(A.Deactivate);
|
|
550
|
+
}).then(() => $(r)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(A.Navigate))), !n);
|
|
578
551
|
}, ce = (r, e, t = "conversation") => {
|
|
579
|
-
const { mainWidget: s, chatWidget:
|
|
580
|
-
return
|
|
581
|
-
|
|
582
|
-
}) : s.container.getAsync("conversation").then((
|
|
552
|
+
const { mainWidget: s, chatWidget: i } = T(r);
|
|
553
|
+
return i ? i.container.getAsync("router").then((n) => {
|
|
554
|
+
n.navigate(t, { id: e.id });
|
|
555
|
+
}) : s.container.getAsync("conversation").then((n) => {
|
|
583
556
|
var a;
|
|
584
|
-
(a =
|
|
557
|
+
(a = n.setConversationEndedBehavior(A.Navigate)) == null || a.then(() => {
|
|
585
558
|
s.container.getAsync("router").then((o) => {
|
|
586
559
|
s.container.getAsync("components").then((c) => {
|
|
587
|
-
const
|
|
560
|
+
const d = c.components().ofType("conversation");
|
|
588
561
|
c.write({
|
|
589
562
|
key: "setConversationProvider",
|
|
590
563
|
attributes: { properties: { providers: [e.clientName] } },
|
|
591
|
-
target:
|
|
564
|
+
target: d,
|
|
592
565
|
provider: "localStorage"
|
|
593
566
|
});
|
|
594
567
|
}).then(() => {
|
|
@@ -597,39 +570,30 @@ const oe = (r, e) => {
|
|
|
597
570
|
});
|
|
598
571
|
});
|
|
599
572
|
});
|
|
600
|
-
},
|
|
601
|
-
var
|
|
602
|
-
class
|
|
573
|
+
}, w = "conversations";
|
|
574
|
+
var A = /* @__PURE__ */ ((r) => (r.Deactivate = "deactivate", r.Navigate = "navigate", r.None = "none", r))(A || {});
|
|
575
|
+
class P {
|
|
603
576
|
constructor(e, t) {
|
|
604
|
-
|
|
605
|
-
d(this, "controllers", []);
|
|
606
|
-
d(this, "providers", []);
|
|
607
|
-
d(this, "disposeProviders", {});
|
|
608
|
-
d(this, "subscriptions", []);
|
|
609
|
-
d(this, "storageWriter", null);
|
|
610
|
-
d(this, "router", null);
|
|
611
|
-
d(this, "buttonQuery", null);
|
|
612
|
-
d(this, "sessionInfo", null);
|
|
613
|
-
this.container = e, this.components = t;
|
|
577
|
+
this.container = e, this.components = t, this.controllers = [], this.providers = [], this.disposeProviders = {}, this.subscriptions = [], this.storageWriter = null, this.router = null, this.buttonQuery = null, this.sessionInfo = null;
|
|
614
578
|
const s = e.get("$widget");
|
|
615
579
|
this.events = s.events.createChild(this);
|
|
616
580
|
}
|
|
617
581
|
initialize() {
|
|
618
|
-
|
|
619
|
-
medium:
|
|
620
|
-
}).then((e) => this.storageWriter = e),
|
|
582
|
+
x(this.container, w, W.Necessary, {
|
|
583
|
+
medium: b.Local
|
|
584
|
+
}).then((e) => this.storageWriter = e), y(this.container, w, b.Local).then(
|
|
621
585
|
(e) => {
|
|
622
586
|
this.buttonQuery = this.components.components().ofType("conversation-return-button"), e && (this.sessionInfo = e, e.id && e.route && this.writeToComponents({ active: !0, alert: { show: !1 } }));
|
|
623
587
|
}
|
|
624
588
|
), this.container.getAsync("router").then((e) => this.router = e), this.events.subscribe("conversation:ended", (e, t) => {
|
|
625
|
-
var s,
|
|
589
|
+
var s, i, n;
|
|
626
590
|
switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
|
|
627
591
|
case "deactivate":
|
|
628
592
|
this.container.get("$widget").deactivate();
|
|
629
593
|
break;
|
|
630
594
|
case "navigate":
|
|
631
|
-
const o = (
|
|
632
|
-
o && ((
|
|
595
|
+
const o = (i = this.router) == null ? void 0 : i.getInitialRoute();
|
|
596
|
+
o && ((n = this.router) == null || n.navigate(o.name));
|
|
633
597
|
break;
|
|
634
598
|
}
|
|
635
599
|
this.writeToComponents({ active: !1 }), this.sessionInfo = null, this.storageWriter && this.storageWriter();
|
|
@@ -639,24 +603,24 @@ class k {
|
|
|
639
603
|
this.subscriptions.push(e);
|
|
640
604
|
}
|
|
641
605
|
static getInstance(e, t = "conversation") {
|
|
642
|
-
return
|
|
643
|
-
let
|
|
644
|
-
return
|
|
606
|
+
return J(e)(() => e.getAsync(t).then((s) => {
|
|
607
|
+
let i = s;
|
|
608
|
+
return i || Q.getInstance(e).then((n) => (i = new P(e, n), i.initialize(), e.registerAsync(t, () => i), i));
|
|
645
609
|
}));
|
|
646
610
|
}
|
|
647
611
|
navigateToConversationIfActive(e) {
|
|
648
|
-
return
|
|
612
|
+
return y(this.container, w, b.Local).then(
|
|
649
613
|
(t) => {
|
|
650
614
|
var s;
|
|
651
615
|
if (t && t.id === e && t.route) {
|
|
652
|
-
const { name:
|
|
653
|
-
(s = this.router) == null || s.navigate(
|
|
616
|
+
const { name: i, params: n } = t.route;
|
|
617
|
+
(s = this.router) == null || s.navigate(i, n);
|
|
654
618
|
}
|
|
655
619
|
}
|
|
656
620
|
);
|
|
657
621
|
}
|
|
658
622
|
setConversationEndedBehavior(e) {
|
|
659
|
-
return
|
|
623
|
+
return y(this.container, w, b.Local).then(
|
|
660
624
|
(t) => {
|
|
661
625
|
let s = t;
|
|
662
626
|
return s ? s.conversationEndedBehavior = e : s = { conversationEndedBehavior: e }, this.sessionInfo = s, this.storageWriter && this.storageWriter(this.sessionInfo) || Promise.resolve();
|
|
@@ -664,13 +628,13 @@ class k {
|
|
|
664
628
|
);
|
|
665
629
|
}
|
|
666
630
|
createController(e, t) {
|
|
667
|
-
return
|
|
668
|
-
const s =
|
|
631
|
+
return u(this, null, function* () {
|
|
632
|
+
const s = U(e), { agents: i } = (yield y(
|
|
669
633
|
this.container,
|
|
670
634
|
s
|
|
671
|
-
)) || { agents: [] },
|
|
635
|
+
)) || { agents: [] }, n = this.controllers.findIndex((o) => o.conversation.id === e);
|
|
672
636
|
let a;
|
|
673
|
-
return
|
|
637
|
+
return n > -1 ? a = this.controllers[n].conversation : a = new ne(this.container, e, t), a.setInitialStorage({ agents: i || [] }), a;
|
|
674
638
|
});
|
|
675
639
|
}
|
|
676
640
|
registerProvider(e, t) {
|
|
@@ -678,41 +642,41 @@ class k {
|
|
|
678
642
|
name: e,
|
|
679
643
|
handler: t
|
|
680
644
|
};
|
|
681
|
-
this.providers.push(s), this.controllers.filter((
|
|
682
|
-
this.invokeHandler(s,
|
|
645
|
+
this.providers.push(s), this.controllers.filter((i) => i.conversation.providers.indexOf(e) > -1).forEach((i) => {
|
|
646
|
+
this.invokeHandler(s, i);
|
|
683
647
|
});
|
|
684
648
|
}
|
|
685
649
|
registerController(e, t) {
|
|
686
|
-
const s = this.controllers.findIndex((
|
|
687
|
-
let
|
|
650
|
+
const s = this.controllers.findIndex((n) => n.conversation.id === e.id);
|
|
651
|
+
let i;
|
|
688
652
|
if (s < 0) {
|
|
689
|
-
|
|
690
|
-
const
|
|
653
|
+
i = { conversation: e, component: t }, this.controllers.push(i);
|
|
654
|
+
const n = (a) => {
|
|
691
655
|
a && this.providers.filter((o) => a.indexOf(o.name) > -1).forEach((o) => {
|
|
692
|
-
this.invokeHandler(o,
|
|
656
|
+
this.invokeHandler(o, i);
|
|
693
657
|
});
|
|
694
658
|
};
|
|
695
659
|
return this.subscriptions.push(
|
|
696
660
|
e.onDispose((a, o) => {
|
|
697
|
-
const c = this.controllers.findIndex((
|
|
661
|
+
const c = this.controllers.findIndex((d) => d.conversation === o);
|
|
698
662
|
c > -1 && this.controllers.splice(c, 1), this.components.components().ofType("conversation-return-button").select().writeProperties({ active: !1 }), this.events.dispatch("conversation:ended", {}, { bubbles: !0 });
|
|
699
663
|
})
|
|
700
664
|
), this.subscriptions.push(
|
|
701
665
|
e.onProvidersChange((a, o) => {
|
|
702
|
-
const { added: c, removed:
|
|
703
|
-
|
|
704
|
-
(this.disposeProviders[
|
|
705
|
-
|
|
666
|
+
const { added: c, removed: d = [] } = o;
|
|
667
|
+
d.forEach((l) => {
|
|
668
|
+
(this.disposeProviders[l] || []).forEach((m) => {
|
|
669
|
+
m();
|
|
706
670
|
});
|
|
707
|
-
}),
|
|
671
|
+
}), n(c);
|
|
708
672
|
})
|
|
709
673
|
), this.subscriptions.push(
|
|
710
674
|
e.onStarted((a, o) => {
|
|
711
|
-
var
|
|
675
|
+
var d, l;
|
|
712
676
|
const c = {
|
|
713
677
|
id: e.id,
|
|
714
|
-
route: (
|
|
715
|
-
conversationEndedBehavior: (
|
|
678
|
+
route: (d = this.router) == null ? void 0 : d.getRouteData(),
|
|
679
|
+
conversationEndedBehavior: (l = this.sessionInfo) == null ? void 0 : l.conversationEndedBehavior
|
|
716
680
|
};
|
|
717
681
|
this.sessionInfo = c, this.storageWriter && this.storageWriter(c), this.writeToComponents({ active: o });
|
|
718
682
|
})
|
|
@@ -720,9 +684,9 @@ class k {
|
|
|
720
684
|
e.onUnreadMessage((a, o) => {
|
|
721
685
|
this.events.dispatch("conversation:unread-message", o), this.writeToComponents({ alert: { show: o } });
|
|
722
686
|
})
|
|
723
|
-
),
|
|
687
|
+
), n(e.providers), !0;
|
|
724
688
|
}
|
|
725
|
-
return
|
|
689
|
+
return i = this.controllers[s], !1;
|
|
726
690
|
}
|
|
727
691
|
writeToComponents(e, t = "conversationReturnButtonState") {
|
|
728
692
|
this.buttonQuery && this.components.write({
|
|
@@ -740,7 +704,7 @@ class k {
|
|
|
740
704
|
s && (this.disposeProviders[e.name] || (this.disposeProviders[e.name] = []), this.disposeProviders[e.name].push(s));
|
|
741
705
|
}
|
|
742
706
|
getComponentRoute() {
|
|
743
|
-
return
|
|
707
|
+
return y(this.container, w, b.Local).then(
|
|
744
708
|
(e) => e == null ? void 0 : e.route
|
|
745
709
|
);
|
|
746
710
|
}
|
|
@@ -753,20 +717,20 @@ class k {
|
|
|
753
717
|
e();
|
|
754
718
|
}), this.controllers = [], this.providers = [];
|
|
755
719
|
}
|
|
756
|
-
static handleContactMethodClick(e, t, s,
|
|
757
|
-
return
|
|
720
|
+
static handleContactMethodClick(e, t, s, i) {
|
|
721
|
+
return u(this, null, function* () {
|
|
758
722
|
if (ae(t)) {
|
|
759
723
|
e.preventDefault();
|
|
760
|
-
let
|
|
761
|
-
|
|
724
|
+
let n = document.getElementById("humany-dynamic-anchor");
|
|
725
|
+
n || (n = document.createElement("a"), n.setAttribute("href", "#"), n.id = "humany-dynamic-anchor", document.body.appendChild(n)), H(t, s, n);
|
|
762
726
|
}
|
|
763
|
-
|
|
727
|
+
H(t, s);
|
|
764
728
|
});
|
|
765
729
|
}
|
|
766
730
|
static handleContactMethodSubmit(e, t) {
|
|
767
|
-
return
|
|
768
|
-
var s,
|
|
769
|
-
return (
|
|
731
|
+
return u(this, null, function* () {
|
|
732
|
+
var s, i;
|
|
733
|
+
return (i = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && i.id ? E(
|
|
770
734
|
e,
|
|
771
735
|
t.body.form.meta.conversation.id,
|
|
772
736
|
t.clientName
|
|
@@ -774,95 +738,95 @@ class k {
|
|
|
774
738
|
});
|
|
775
739
|
}
|
|
776
740
|
}
|
|
777
|
-
const de = (r, e) => r.reduce((t, s,
|
|
741
|
+
const de = (r, e) => r.reduce((t, s, i) => {
|
|
778
742
|
var a, o;
|
|
779
|
-
const
|
|
780
|
-
content: [
|
|
743
|
+
const n = g(p({}, s), {
|
|
744
|
+
content: [g(p({}, s.content), { key: s.key })]
|
|
781
745
|
});
|
|
782
|
-
if (t.length > 0 && s.type !==
|
|
746
|
+
if (t.length > 0 && s.type !== C.System) {
|
|
783
747
|
const c = t[t.length - 1];
|
|
784
748
|
if ((!e && e !== 0 || Math.abs(c.timestamp - s.timestamp) < e) && ((a = c.sender) == null ? void 0 : a.name) === ((o = s.sender) == null ? void 0 : o.name) && c.type === s.type)
|
|
785
|
-
return c.timestamp = s.timestamp, c.content.push(
|
|
749
|
+
return c.timestamp = s.timestamp, c.content.push(g(p({}, s.content), { key: s.key })), t;
|
|
786
750
|
}
|
|
787
|
-
return t.push(
|
|
751
|
+
return t.push(n), t;
|
|
788
752
|
}, []), be = (r) => Promise.all([
|
|
789
|
-
|
|
753
|
+
P.getInstance(r),
|
|
790
754
|
r.getAsync("router")
|
|
791
|
-
]).then(([e, t]) =>
|
|
755
|
+
]).then(([e, t]) => Y(
|
|
792
756
|
r,
|
|
793
757
|
"conversation",
|
|
794
|
-
import("./conversation.
|
|
795
|
-
(s) =>
|
|
796
|
-
const { rehydrate:
|
|
797
|
-
const { providers:
|
|
798
|
-
if (
|
|
799
|
-
const
|
|
800
|
-
return o.setProviders(
|
|
758
|
+
import("./conversation-wrapper.bfcf4c5c.js"),
|
|
759
|
+
(s) => u(void 0, null, function* () {
|
|
760
|
+
const { rehydrate: i = !1 } = s.properties(), a = t.getRouteData().params.id || s.node.name || "component", o = yield e.createController(a, { rehydrate: i }), c = e.registerController(o, s), d = 3 * 60 * 1e3, l = (v) => {
|
|
761
|
+
const { providers: h = [] } = v;
|
|
762
|
+
if (h) {
|
|
763
|
+
const f = Array.isArray(h) ? h : [h];
|
|
764
|
+
return o.setProviders(f), f;
|
|
801
765
|
}
|
|
802
766
|
};
|
|
803
|
-
|
|
804
|
-
const
|
|
805
|
-
const { loading:
|
|
767
|
+
l(s.properties(l)), o.setComponentMountedState(!0);
|
|
768
|
+
const m = (v) => {
|
|
769
|
+
const { loading: h, typingActors: f, messages: k } = v;
|
|
806
770
|
s.writeProperties({
|
|
807
|
-
loading:
|
|
808
|
-
typingActors:
|
|
809
|
-
messages: de(
|
|
771
|
+
loading: h,
|
|
772
|
+
typingActors: f,
|
|
773
|
+
messages: de(k, d)
|
|
810
774
|
});
|
|
811
775
|
};
|
|
812
|
-
|
|
813
|
-
if (
|
|
814
|
-
const { preventDefault:
|
|
815
|
-
if (
|
|
816
|
-
|
|
817
|
-
|
|
776
|
+
m(o.getMessageStream()), c && (s.writeProperties({ conversationControllerId: o.id }), s.actions.create("user-submit", (v, h) => {
|
|
777
|
+
if (h) {
|
|
778
|
+
const { preventDefault: f, validationPromise: k } = h;
|
|
779
|
+
if (f) {
|
|
780
|
+
k && k().then((D) => {
|
|
781
|
+
D && o.user.print(D);
|
|
818
782
|
});
|
|
819
783
|
return;
|
|
820
784
|
}
|
|
821
785
|
}
|
|
822
|
-
o.user.print(
|
|
823
|
-
}), s.actions.create("user-typing", (
|
|
824
|
-
}), s.actions.create("form", (
|
|
825
|
-
}), s.actions.create("action", (
|
|
826
|
-
}), s.actions.create("overlay-mounted", (
|
|
827
|
-
}), s.actions.create("show-overlay", (
|
|
786
|
+
o.user.print(v.text);
|
|
787
|
+
}), s.actions.create("user-typing", (v, h) => {
|
|
788
|
+
}), s.actions.create("form", (v, h) => {
|
|
789
|
+
}), s.actions.create("action", (v, h) => {
|
|
790
|
+
}), s.actions.create("overlay-mounted", (v, h) => {
|
|
791
|
+
}), s.actions.create("show-overlay", (v, h) => {
|
|
828
792
|
s.writeProperties({
|
|
829
793
|
overlay: { conversation: !1, secondary: !1 }
|
|
830
794
|
});
|
|
831
|
-
}), s.actions.create("hide-overlay", (
|
|
795
|
+
}), s.actions.create("hide-overlay", (v, h) => {
|
|
832
796
|
s.writeProperties({
|
|
833
797
|
overlay: null
|
|
834
798
|
});
|
|
835
|
-
}), s.actions.create("show-overlay-conversation", (
|
|
799
|
+
}), s.actions.create("show-overlay-conversation", (v, h) => {
|
|
836
800
|
s.writeProperties({
|
|
837
801
|
overlay: { conversation: !0, secondary: !1 }
|
|
838
802
|
});
|
|
839
|
-
}), s.actions.create("hide-overlay-conversation", (
|
|
803
|
+
}), s.actions.create("hide-overlay-conversation", (v, h) => {
|
|
840
804
|
s.writeProperties({
|
|
841
805
|
overlay: { conversation: !1, secondary: !1 }
|
|
842
806
|
});
|
|
843
807
|
}));
|
|
844
|
-
const
|
|
808
|
+
const q = o.events.subscribe(
|
|
845
809
|
"conversation:updated",
|
|
846
|
-
(
|
|
847
|
-
|
|
810
|
+
(v, h) => {
|
|
811
|
+
m(h);
|
|
848
812
|
}
|
|
849
813
|
);
|
|
850
814
|
return () => {
|
|
851
|
-
o.setComponentMountedState(!1),
|
|
815
|
+
o.setComponentMountedState(!1), q(), o.active || m({ messages: [], typingActors: [], loading: !1 });
|
|
852
816
|
};
|
|
853
817
|
}),
|
|
854
818
|
{ reuseController: !0 }
|
|
855
819
|
)), we = (r) => Promise.all([
|
|
856
|
-
|
|
857
|
-
|
|
820
|
+
Q.getInstance(r),
|
|
821
|
+
P.getInstance(r),
|
|
858
822
|
r.getAsync("router")
|
|
859
823
|
]).then(
|
|
860
|
-
([e, t, s]) =>
|
|
824
|
+
([e, t, s]) => X(
|
|
861
825
|
r,
|
|
862
826
|
"conversation-return-button",
|
|
863
827
|
import("./return-button.fb63a16e.js"),
|
|
864
|
-
(
|
|
865
|
-
|
|
828
|
+
(i) => {
|
|
829
|
+
i.actions.create("toggle", (n = {}) => {
|
|
866
830
|
var a;
|
|
867
831
|
(a = t.getComponentRoute()) == null || a.then((o) => {
|
|
868
832
|
o && s.navigate(o.name, o.params);
|
|
@@ -872,8 +836,8 @@ const de = (r, e) => r.reduce((t, s, n) => {
|
|
|
872
836
|
)
|
|
873
837
|
);
|
|
874
838
|
var he = /* @__PURE__ */ ((r) => (r.LinkList = "link-list", r.Separator = "separator", r.ButtonList = "button-list", r.Text = "text", r.HTML = "html", r.VideoRequest = "video-request", r))(he || {});
|
|
875
|
-
const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) =>
|
|
876
|
-
(yield
|
|
839
|
+
const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) => u(void 0, null, function* () {
|
|
840
|
+
(yield P.getInstance(r)).addSubscription(
|
|
877
841
|
s.registerComponent(
|
|
878
842
|
e,
|
|
879
843
|
Z(() => t)
|
|
@@ -882,12 +846,12 @@ const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) => v(void 0, nu
|
|
|
882
846
|
}));
|
|
883
847
|
export {
|
|
884
848
|
be as ConversationComponent,
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
849
|
+
ne as ConversationController,
|
|
850
|
+
A as ConversationEndedBehavior,
|
|
851
|
+
ie as ConversationEntry,
|
|
888
852
|
he as ConversationMessageListItemType,
|
|
889
|
-
|
|
890
|
-
|
|
853
|
+
C as ConversationMessageType,
|
|
854
|
+
P as ConversationPlatform,
|
|
891
855
|
we as ConversationReturnButtonComponent,
|
|
892
856
|
Pe as registerCustomMessageComponent
|
|
893
857
|
};
|