@telia-ace/widget-conversation 1.0.36 → 1.0.37-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/conversation-controller.d.ts +8 -0
- package/dist/conversation-history.d.ts +26 -0
- package/dist/conversation-provider.d.ts +7 -0
- package/dist/{conversation.bc31361a.js → conversation.d6cacfa5.js} +1 -1
- package/dist/{conversation.bc31361a.js.map → conversation.d6cacfa5.js.map} +1 -1
- package/dist/index.js +332 -233
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,49 +1,140 @@
|
|
|
1
1
|
var j = Object.defineProperty, G = Object.defineProperties;
|
|
2
2
|
var J = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var x = Object.getOwnPropertySymbols;
|
|
4
|
+
var $ = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var T = (r, e, t) => e in r ? j(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, m = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
7
|
+
$.call(e, t) && T(r, t, e[t]);
|
|
8
|
+
if (x)
|
|
9
|
+
for (var t of x(e))
|
|
10
|
+
_.call(e, t) && T(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, b = (r, e) => G(r, J(e));
|
|
13
|
+
var B = (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 && x)
|
|
18
|
+
for (var s of x(r))
|
|
19
|
+
e.indexOf(s) < 0 && _.call(r, s) && (t[s] = r[s]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var d = (r, e, t) => (
|
|
23
|
-
var v = (r, e, t) => new Promise((s,
|
|
24
|
-
var
|
|
22
|
+
var d = (r, e, t) => (T(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
23
|
+
var v = (r, e, t) => new Promise((s, i) => {
|
|
24
|
+
var n = (c) => {
|
|
25
25
|
try {
|
|
26
26
|
o(t.next(c));
|
|
27
27
|
} catch (h) {
|
|
28
|
-
|
|
28
|
+
i(h);
|
|
29
29
|
}
|
|
30
30
|
}, a = (c) => {
|
|
31
31
|
try {
|
|
32
32
|
o(t.throw(c));
|
|
33
33
|
} catch (h) {
|
|
34
|
-
|
|
34
|
+
i(h);
|
|
35
35
|
}
|
|
36
|
-
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(
|
|
36
|
+
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, a);
|
|
37
37
|
o((t = t.apply(r, e)).next());
|
|
38
38
|
});
|
|
39
39
|
import { ComponentPlatform as K } from "@telia-ace/widget-core";
|
|
40
|
-
import { createStorageWriter as
|
|
41
|
-
import { uuid as
|
|
40
|
+
import { createStorageWriter as D, StorageCategory as N, readStorage as w, StorageMedium as A, StorageScope as V } from "@telia-ace/widget-services";
|
|
41
|
+
import { uuid as U, lock as Y } from "@telia-ace/widget-utilities";
|
|
42
42
|
import { FormBuilder as X } from "@telia-ace/widget-forms";
|
|
43
|
-
import { closeAllModals as
|
|
44
|
-
import { createReactComponent as
|
|
43
|
+
import { closeAllModals as L } from "@telia-ace/widget-plugins";
|
|
44
|
+
import { createReactComponent as q } from "@telia-ace/widget-ui";
|
|
45
45
|
import { lazy as Z } from "react";
|
|
46
|
-
class
|
|
46
|
+
class ee {
|
|
47
|
+
constructor(e) {
|
|
48
|
+
d(this, "cache", /* @__PURE__ */ new Map());
|
|
49
|
+
d(this, "subscriptions", []);
|
|
50
|
+
this.controller = e;
|
|
51
|
+
const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (i, n) => {
|
|
52
|
+
n.type === "contact-method" && this.cache.set(n.response.id, n.response);
|
|
53
|
+
});
|
|
54
|
+
this.subscriptions.push(s);
|
|
55
|
+
}
|
|
56
|
+
getConversationLogs() {
|
|
57
|
+
return this.controller.messages.reduce((t, s) => {
|
|
58
|
+
const i = I(s), { key: n, content: a, type: o, sender: c, timestamp: h } = i.content, u = this.parseEntry(a, o, c, h);
|
|
59
|
+
return u && t.push(u), t;
|
|
60
|
+
}, []);
|
|
61
|
+
}
|
|
62
|
+
parseEntry(e, t, s, i) {
|
|
63
|
+
const n = (h) => {
|
|
64
|
+
let u = [], l = [], f;
|
|
65
|
+
if (Array.isArray(h)) {
|
|
66
|
+
const [p, y] = h;
|
|
67
|
+
f = y;
|
|
68
|
+
} else
|
|
69
|
+
f = h;
|
|
70
|
+
return this.createMessageContent(f).length && (l = [...l, this.createMessageContent(f)]), u = [...u, ...this.createMessageOptions(f)], {
|
|
71
|
+
messagesAsList: l,
|
|
72
|
+
options: u
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
let a = [], o = [];
|
|
76
|
+
if (Array.isArray(e.items)) {
|
|
77
|
+
const { items: h } = e;
|
|
78
|
+
h.forEach((u) => {
|
|
79
|
+
const l = n(u);
|
|
80
|
+
a = [...a, ...l.options], o = [...o, ...l.messagesAsList];
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
const h = n(e);
|
|
84
|
+
a = [...a, ...h.options], o = [...o, ...h.messagesAsList];
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
options: a,
|
|
88
|
+
message: o.length ? o.join(`
|
|
89
|
+
`) : void 0,
|
|
90
|
+
source: this.createMessageSource(t),
|
|
91
|
+
alias: this.createAlias(t, s),
|
|
92
|
+
timestamp: i
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
createMessageSource(e) {
|
|
96
|
+
return e;
|
|
97
|
+
}
|
|
98
|
+
createAlias(e, t) {
|
|
99
|
+
return e === S.System ? "system" : (t == null ? void 0 : t.name) || "Me";
|
|
100
|
+
}
|
|
101
|
+
handleContactMethod(e) {
|
|
102
|
+
if (!this.cache.has(e))
|
|
103
|
+
return;
|
|
104
|
+
const t = this.cache.get(e);
|
|
105
|
+
let s = "";
|
|
106
|
+
return s = this.appendText(s, `${t.clientName}:`), s = this.appendText(s, t.title), t.description && (s = this.appendText(s, t.title)), s;
|
|
107
|
+
}
|
|
108
|
+
getDetails(e, t = !0) {
|
|
109
|
+
if (!e)
|
|
110
|
+
return "";
|
|
111
|
+
const { header: s, title: i, label: n, description: a, text: o, html: c, body: h, contactMethodId: u } = e;
|
|
112
|
+
let l = "";
|
|
113
|
+
if (u) {
|
|
114
|
+
const f = this.handleContactMethod(u.toString());
|
|
115
|
+
f && (l = this.appendText(l, f, t));
|
|
116
|
+
}
|
|
117
|
+
return s && (l = this.appendText(l, s, t)), i && (l = this.appendText(l, i, t)), a && (l = this.appendText(l, a, t)), o && (l = this.appendText(l, o, t)), n && (l = this.appendText(l, n, t)), c && (l = this.appendText(l, c, t)), h && typeof h == "string" && (l = this.appendText(l, h, t)), l;
|
|
118
|
+
}
|
|
119
|
+
createMessageContent(e) {
|
|
120
|
+
let t = "";
|
|
121
|
+
return t = this.getDetails(e), t;
|
|
122
|
+
}
|
|
123
|
+
createMessageOptions(e) {
|
|
124
|
+
let t = [];
|
|
125
|
+
return e != null && e.actions && (t = e.actions.map((s) => this.getDetails(s, !1))), t;
|
|
126
|
+
}
|
|
127
|
+
appendText(e, t, s = !0) {
|
|
128
|
+
return s && e.length ? `${e}
|
|
129
|
+
${t}` : e.length ? `${e} ${t}` : t;
|
|
130
|
+
}
|
|
131
|
+
dispose() {
|
|
132
|
+
this.subscriptions.forEach((e) => {
|
|
133
|
+
e();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
class M {
|
|
47
138
|
constructor(e, t) {
|
|
48
139
|
d(this, "id");
|
|
49
140
|
d(this, "name");
|
|
@@ -53,27 +144,27 @@ class x {
|
|
|
53
144
|
name: this.name,
|
|
54
145
|
avatar: this.avatar,
|
|
55
146
|
id: this.id
|
|
56
|
-
},
|
|
147
|
+
}, i = I(e, t);
|
|
57
148
|
return this.provider.createEntry(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
149
|
+
i.key,
|
|
150
|
+
i.content,
|
|
151
|
+
S.Agent,
|
|
61
152
|
s,
|
|
62
|
-
|
|
153
|
+
i.timestamp
|
|
63
154
|
);
|
|
64
155
|
});
|
|
65
156
|
d(this, "typing", () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }));
|
|
66
|
-
this.provider = e, this.id = t.id ||
|
|
157
|
+
this.provider = e, this.id = t.id || U(), this.name = t.name, this.avatar = t.avatar;
|
|
67
158
|
}
|
|
68
159
|
update(e) {
|
|
69
|
-
var
|
|
160
|
+
var i;
|
|
70
161
|
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), (
|
|
162
|
+
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
163
|
agent: this
|
|
73
164
|
});
|
|
74
165
|
}
|
|
75
166
|
}
|
|
76
|
-
class
|
|
167
|
+
class R {
|
|
77
168
|
constructor(e, t, s) {
|
|
78
169
|
d(this, "subscriptions", []);
|
|
79
170
|
d(this, "options");
|
|
@@ -83,15 +174,15 @@ class T {
|
|
|
83
174
|
};
|
|
84
175
|
}
|
|
85
176
|
static create(e, t, s) {
|
|
86
|
-
return new
|
|
177
|
+
return new R(e, t, s);
|
|
87
178
|
}
|
|
88
179
|
createAgent(e = {}) {
|
|
89
180
|
var t;
|
|
90
181
|
if (this.controller) {
|
|
91
|
-
const s = this.controller.getAgentById(e.id),
|
|
182
|
+
const s = this.controller.getAgentById(e.id), i = s ? new M(this, m(m({}, s), e)) : new M(this, e);
|
|
92
183
|
return s || (t = this.controller) == null || t.events.dispatch("conversation:agent-created", {
|
|
93
|
-
agent:
|
|
94
|
-
}),
|
|
184
|
+
agent: i
|
|
185
|
+
}), i;
|
|
95
186
|
}
|
|
96
187
|
}
|
|
97
188
|
print(e) {
|
|
@@ -106,9 +197,9 @@ class T {
|
|
|
106
197
|
return this.controller ? this.controller.loader() : () => () => {
|
|
107
198
|
};
|
|
108
199
|
}
|
|
109
|
-
createEntry(e, t, s,
|
|
200
|
+
createEntry(e, t, s, i, n) {
|
|
110
201
|
var a;
|
|
111
|
-
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s,
|
|
202
|
+
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, i, n);
|
|
112
203
|
}
|
|
113
204
|
dispose() {
|
|
114
205
|
var e;
|
|
@@ -118,6 +209,10 @@ class T {
|
|
|
118
209
|
var e;
|
|
119
210
|
return ((e = this.controller) == null ? void 0 : e.isRehydrated()) || Promise.resolve(!1);
|
|
120
211
|
}
|
|
212
|
+
getHistory() {
|
|
213
|
+
var e;
|
|
214
|
+
return ((e = this.controller) == null ? void 0 : e.getHistory()) || [];
|
|
215
|
+
}
|
|
121
216
|
complete() {
|
|
122
217
|
var e;
|
|
123
218
|
(e = this.controller) == null || e.onCompleteProvider();
|
|
@@ -147,8 +242,8 @@ class T {
|
|
|
147
242
|
}
|
|
148
243
|
}
|
|
149
244
|
}
|
|
150
|
-
const
|
|
151
|
-
class
|
|
245
|
+
const F = (r) => `conversation-${r}`;
|
|
246
|
+
class te {
|
|
152
247
|
constructor() {
|
|
153
248
|
d(this, "_locking", Promise.resolve());
|
|
154
249
|
d(this, "_locks", 0);
|
|
@@ -159,31 +254,31 @@ class ee {
|
|
|
159
254
|
lock() {
|
|
160
255
|
this._locks += 1;
|
|
161
256
|
let e, t = new Promise(
|
|
162
|
-
(
|
|
163
|
-
this._locks -= 1,
|
|
257
|
+
(i) => e = () => {
|
|
258
|
+
this._locks -= 1, i();
|
|
164
259
|
}
|
|
165
260
|
), s = this._locking.then(() => e);
|
|
166
261
|
return this._locking = this._locking.then(() => t), s;
|
|
167
262
|
}
|
|
168
263
|
}
|
|
169
|
-
class
|
|
264
|
+
class se {
|
|
170
265
|
constructor(e, t, s) {
|
|
171
266
|
d(this, "sessionStorageKey");
|
|
172
|
-
d(this, "locker", new
|
|
267
|
+
d(this, "locker", new te());
|
|
173
268
|
d(this, "initialStoredAgents", []);
|
|
174
|
-
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey =
|
|
269
|
+
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey = F(t.id), t.onStarted(() => v(this, null, function* () {
|
|
175
270
|
if (t.messages.length > 0)
|
|
176
271
|
return;
|
|
177
|
-
const { agents:
|
|
178
|
-
|
|
179
|
-
const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new
|
|
180
|
-
|
|
272
|
+
const { agents: i } = yield this.read(), n = [];
|
|
273
|
+
i && i.forEach((o) => {
|
|
274
|
+
const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new M(h, { name: o.name, avatar: o.avatar, id: o.id });
|
|
275
|
+
n.push(u);
|
|
181
276
|
});
|
|
182
277
|
const { messages: a } = yield this.read();
|
|
183
278
|
a.forEach((o) => {
|
|
184
279
|
switch (o.type) {
|
|
185
280
|
case "agent": {
|
|
186
|
-
const c =
|
|
281
|
+
const c = n.find((h) => {
|
|
187
282
|
var u;
|
|
188
283
|
return h.id === ((u = o.sender) == null ? void 0 : u.id);
|
|
189
284
|
});
|
|
@@ -203,23 +298,23 @@ class te {
|
|
|
203
298
|
t.print(o.content.items || o.content);
|
|
204
299
|
}
|
|
205
300
|
});
|
|
206
|
-
})), t.onMessageCreated((
|
|
207
|
-
this.write(
|
|
208
|
-
})), t.events.subscribe("conversation:agent-created", (
|
|
301
|
+
})), t.onMessageCreated((i, n) => v(this, null, function* () {
|
|
302
|
+
this.write(n.message, "messages");
|
|
303
|
+
})), t.events.subscribe("conversation:agent-created", (i, n) => v(this, null, function* () {
|
|
209
304
|
const a = {
|
|
210
|
-
id:
|
|
211
|
-
name:
|
|
212
|
-
avatar:
|
|
213
|
-
providerName:
|
|
305
|
+
id: n.agent.id,
|
|
306
|
+
name: n.agent.name,
|
|
307
|
+
avatar: n.agent.avatar,
|
|
308
|
+
providerName: n.agent.provider.name
|
|
214
309
|
};
|
|
215
310
|
yield this.write(a, "agents");
|
|
216
|
-
})), t.events.subscribe("conversation:agent-updated", (
|
|
311
|
+
})), t.events.subscribe("conversation:agent-updated", (i, n) => v(this, null, function* () {
|
|
217
312
|
const { agents: a } = yield this.read();
|
|
218
313
|
yield this.write(
|
|
219
314
|
[
|
|
220
|
-
...a.map((o) => o.id ===
|
|
221
|
-
name:
|
|
222
|
-
avatar:
|
|
315
|
+
...a.map((o) => o.id === n.agent.id ? b(m({}, o), {
|
|
316
|
+
name: n.agent.name,
|
|
317
|
+
avatar: n.agent.avatar
|
|
223
318
|
}) : o)
|
|
224
319
|
],
|
|
225
320
|
"agents",
|
|
@@ -244,55 +339,55 @@ class te {
|
|
|
244
339
|
return v(this, null, function* () {
|
|
245
340
|
if (!this.enabled)
|
|
246
341
|
return;
|
|
247
|
-
const
|
|
248
|
-
return
|
|
342
|
+
const i = yield this.locker.lock();
|
|
343
|
+
return D(
|
|
249
344
|
this.container,
|
|
250
345
|
this.sessionStorageKey,
|
|
251
|
-
|
|
252
|
-
).then((
|
|
346
|
+
N.Necessary
|
|
347
|
+
).then((n) => v(this, null, function* () {
|
|
253
348
|
if (s === "add") {
|
|
254
349
|
const a = yield this.read();
|
|
255
350
|
if (t === "messages" && a.messages.findIndex((c) => c.key === e.key) > -1) {
|
|
256
|
-
|
|
351
|
+
i();
|
|
257
352
|
return;
|
|
258
353
|
}
|
|
259
|
-
let o =
|
|
260
|
-
return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]),
|
|
261
|
-
|
|
354
|
+
let o = m({}, a);
|
|
355
|
+
return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]), n(m(m({}, a), o)).then(() => {
|
|
356
|
+
i();
|
|
262
357
|
});
|
|
263
358
|
}
|
|
264
359
|
if (s === "update" && t === "agents") {
|
|
265
360
|
const a = yield this.read();
|
|
266
|
-
return
|
|
361
|
+
return n(b(m({}, a), {
|
|
267
362
|
agents: e
|
|
268
363
|
})).then(() => {
|
|
269
|
-
|
|
364
|
+
i();
|
|
270
365
|
});
|
|
271
366
|
}
|
|
272
|
-
return
|
|
273
|
-
|
|
367
|
+
return n(e).then(() => {
|
|
368
|
+
i();
|
|
274
369
|
});
|
|
275
370
|
}));
|
|
276
371
|
});
|
|
277
372
|
}
|
|
278
373
|
read() {
|
|
279
374
|
return v(this, null, function* () {
|
|
280
|
-
return
|
|
375
|
+
return w(this.container, this.sessionStorageKey).then((e) => e || {
|
|
281
376
|
messages: [],
|
|
282
377
|
agents: []
|
|
283
378
|
});
|
|
284
379
|
});
|
|
285
380
|
}
|
|
286
381
|
}
|
|
287
|
-
const
|
|
288
|
-
class
|
|
382
|
+
const re = se;
|
|
383
|
+
class ie {
|
|
289
384
|
constructor(e) {
|
|
290
385
|
d(this, "print", (e, t) => {
|
|
291
|
-
const s =
|
|
386
|
+
const s = I(e, t);
|
|
292
387
|
return this.controller.createEntry(
|
|
293
388
|
s.key,
|
|
294
389
|
s.content,
|
|
295
|
-
|
|
390
|
+
S.User,
|
|
296
391
|
void 0,
|
|
297
392
|
s.timestamp
|
|
298
393
|
);
|
|
@@ -301,14 +396,14 @@ class re {
|
|
|
301
396
|
}
|
|
302
397
|
}
|
|
303
398
|
const W = (r, e, t) => v(void 0, null, function* () {
|
|
304
|
-
const s = yield r.getAsync("conversation"),
|
|
305
|
-
if (
|
|
306
|
-
const a = [...
|
|
399
|
+
const s = yield r.getAsync("conversation"), i = yield r.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
|
|
400
|
+
if (n) {
|
|
401
|
+
const a = [...n.conversation.providers];
|
|
307
402
|
a.forEach((c) => {
|
|
308
|
-
|
|
309
|
-
}),
|
|
310
|
-
const o =
|
|
311
|
-
|
|
403
|
+
n.conversation.setProviderOptions(c, { silent: !0 });
|
|
404
|
+
}), n.conversation.queueProviders(a), n.conversation.setProviders([t]);
|
|
405
|
+
const o = i.components().ofType("conversation");
|
|
406
|
+
i.write({
|
|
312
407
|
key: "setConversationProvider",
|
|
313
408
|
attributes: {
|
|
314
409
|
properties: { providers: [t] }
|
|
@@ -333,40 +428,40 @@ class ne {
|
|
|
333
428
|
return typeof e == "string" ? { body: e } : e.length > -1 && typeof e == "object" ? { items: e } : e;
|
|
334
429
|
}
|
|
335
430
|
}
|
|
336
|
-
var
|
|
337
|
-
const
|
|
338
|
-
let t, s = (e == null ? void 0 : e.key) ||
|
|
431
|
+
var S = /* @__PURE__ */ ((r) => (r.User = "user", r.Agent = "agent", r.System = "system", r))(S || {});
|
|
432
|
+
const I = (r, e) => {
|
|
433
|
+
let t, s = (e == null ? void 0 : e.key) || U(), i = Date.now();
|
|
339
434
|
if (Array.isArray(r) && r.length > -1)
|
|
340
435
|
typeof r[0] == "string" ? t = { items: [r] } : t = { items: r };
|
|
341
436
|
else if (typeof r == "string")
|
|
342
437
|
t = { body: r };
|
|
343
438
|
else if (r = r || {}, r.type)
|
|
344
|
-
t =
|
|
439
|
+
t = m({}, r);
|
|
345
440
|
else {
|
|
346
441
|
if (t = {
|
|
347
442
|
body: r.body,
|
|
348
443
|
actions: r.actions,
|
|
349
444
|
title: r.title
|
|
350
|
-
}, r.key && (s = r.key), r.timestamp && (
|
|
351
|
-
const
|
|
352
|
-
r.form(
|
|
353
|
-
const a =
|
|
445
|
+
}, r.key && (s = r.key), r.timestamp && (i = r.timestamp), typeof r.form == "function") {
|
|
446
|
+
const n = X.create(s);
|
|
447
|
+
r.form(n);
|
|
448
|
+
const a = n.get();
|
|
354
449
|
t.form = a;
|
|
355
450
|
}
|
|
356
|
-
r.timestamp === null && (
|
|
451
|
+
r.timestamp === null && (i = null);
|
|
357
452
|
}
|
|
358
|
-
return { content: t, key: s, timestamp:
|
|
359
|
-
},
|
|
453
|
+
return { content: t, key: s, timestamp: i };
|
|
454
|
+
}, z = (r, e) => {
|
|
360
455
|
if (!e)
|
|
361
456
|
return;
|
|
362
|
-
const t = JSON.stringify(e), s = r.findIndex((
|
|
457
|
+
const t = JSON.stringify(e), s = r.findIndex((i) => t === JSON.stringify(i));
|
|
363
458
|
if (s > -1)
|
|
364
459
|
return r.splice(s, 1);
|
|
365
460
|
};
|
|
366
|
-
class
|
|
461
|
+
class oe {
|
|
367
462
|
constructor(e, t, s) {
|
|
368
463
|
d(this, "formHandlers", {});
|
|
369
|
-
d(this, "user", new
|
|
464
|
+
d(this, "user", new ie(this));
|
|
370
465
|
d(this, "events");
|
|
371
466
|
d(this, "providers", []);
|
|
372
467
|
d(this, "active", !1);
|
|
@@ -377,8 +472,9 @@ class ie {
|
|
|
377
472
|
d(this, "store");
|
|
378
473
|
d(this, "messages", []);
|
|
379
474
|
d(this, "typingActors", []);
|
|
475
|
+
d(this, "conversationHistory");
|
|
380
476
|
d(this, "print", (e) => {
|
|
381
|
-
const t =
|
|
477
|
+
const t = I(e);
|
|
382
478
|
return this.createEntry(
|
|
383
479
|
t.key,
|
|
384
480
|
t.content,
|
|
@@ -388,26 +484,26 @@ class ie {
|
|
|
388
484
|
);
|
|
389
485
|
});
|
|
390
486
|
this.container = e, this.id = t;
|
|
391
|
-
const
|
|
392
|
-
this.events =
|
|
487
|
+
const i = e.get("$widget");
|
|
488
|
+
this.events = i.events.createChild(this), this.store = new re(e, this, s.rehydrate), this.conversationHistory = new ee(this);
|
|
393
489
|
}
|
|
394
490
|
setInitialStorage(e) {
|
|
395
491
|
this.store.setInitialData(e);
|
|
396
492
|
}
|
|
397
493
|
setProviders(e) {
|
|
398
494
|
const t = [], s = [];
|
|
399
|
-
this.providers.reduce((
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
}), e.forEach((
|
|
403
|
-
this.providers.indexOf(
|
|
495
|
+
this.providers.reduce((i, n) => (e.indexOf(n) === -1 && i.push(n), i), []).forEach((i) => {
|
|
496
|
+
const n = this.providers.indexOf(i);
|
|
497
|
+
n > -1 && (t.push(i), this.providers.splice(n, 1));
|
|
498
|
+
}), e.forEach((i) => {
|
|
499
|
+
this.providers.indexOf(i) === -1 && (s.push(i), this.providers.push(i));
|
|
404
500
|
}), (s.length || t.length) && this.events.dispatch("conversation:providers-changed", { added: s, removed: t });
|
|
405
501
|
}
|
|
406
502
|
createProvider(e) {
|
|
407
503
|
const t = this.providerIndex(e);
|
|
408
504
|
if (t > -1)
|
|
409
505
|
return this.registeredProviders[t];
|
|
410
|
-
const s =
|
|
506
|
+
const s = R.create(e, this.container, this);
|
|
411
507
|
return this.registeredProviders.push(s), s;
|
|
412
508
|
}
|
|
413
509
|
providerIndex(e) {
|
|
@@ -418,7 +514,7 @@ class ie {
|
|
|
418
514
|
return this.store.getStoredAgent(e);
|
|
419
515
|
}
|
|
420
516
|
dispose() {
|
|
421
|
-
this.registeredProviders.forEach((e) => e.dispose()), this.messages = [], this.events.dispatch("conversation:controller-disposed", this), this.active = !1;
|
|
517
|
+
this.conversationHistory.dispose(), this.registeredProviders.forEach((e) => e.dispose()), this.messages = [], this.events.dispatch("conversation:controller-disposed", this), this.active = !1;
|
|
422
518
|
}
|
|
423
519
|
onDispose(e) {
|
|
424
520
|
return this.events.subscribe("conversation:controller-disposed", e);
|
|
@@ -462,19 +558,19 @@ class ie {
|
|
|
462
558
|
onUnreadMessage(e) {
|
|
463
559
|
return this.events.subscribe("conversation:unread-message", e);
|
|
464
560
|
}
|
|
465
|
-
createEntry(e, t, s,
|
|
561
|
+
createEntry(e, t, s, i, n) {
|
|
466
562
|
const a = {
|
|
467
563
|
key: e,
|
|
468
564
|
content: t,
|
|
469
565
|
type: s,
|
|
470
|
-
sender:
|
|
471
|
-
timestamp:
|
|
566
|
+
sender: i || null,
|
|
567
|
+
timestamp: n || n === null ? n : Date.now()
|
|
472
568
|
};
|
|
473
|
-
this.messages.push(a), a.type === "agent" &&
|
|
569
|
+
this.messages.push(a), a.type === "agent" && z(this.typingActors, i);
|
|
474
570
|
const o = new ne((c) => {
|
|
475
571
|
if (c !== null) {
|
|
476
|
-
const h = c, { timestamp: u = void 0 } = h,
|
|
477
|
-
a.content =
|
|
572
|
+
const h = c, { timestamp: u = void 0 } = h, l = B(h, ["timestamp"]);
|
|
573
|
+
a.content = l, u && (a.timestamp = u);
|
|
478
574
|
} else {
|
|
479
575
|
const u = this.messages.indexOf(a);
|
|
480
576
|
a.content = null, u > -1 && this.messages.splice(u, 1);
|
|
@@ -499,7 +595,7 @@ class ie {
|
|
|
499
595
|
}
|
|
500
596
|
setTypingState(e, t) {
|
|
501
597
|
return this.typingActors.indexOf(e) === -1 && (this.typingActors.push(e), this.update()), () => {
|
|
502
|
-
|
|
598
|
+
z(this.typingActors, e), this.update();
|
|
503
599
|
};
|
|
504
600
|
}
|
|
505
601
|
loader() {
|
|
@@ -510,34 +606,37 @@ class ie {
|
|
|
510
606
|
};
|
|
511
607
|
}
|
|
512
608
|
submitForm(e, t) {
|
|
513
|
-
this.formHandlers[e] = m(
|
|
609
|
+
this.formHandlers[e] = b(m({}, this.formHandlers[e]), { submit: t });
|
|
514
610
|
}
|
|
515
611
|
validateForm(e, t) {
|
|
516
|
-
this.formHandlers[e] = m(
|
|
612
|
+
this.formHandlers[e] = b(m({}, this.formHandlers[e]), { validate: t });
|
|
613
|
+
}
|
|
614
|
+
getHistory() {
|
|
615
|
+
return this.conversationHistory.getConversationLogs();
|
|
517
616
|
}
|
|
518
617
|
}
|
|
519
|
-
const
|
|
618
|
+
const ae = (r, e) => {
|
|
520
619
|
const t = r.split("_contact");
|
|
521
620
|
return e.widgets.get(t[0]);
|
|
522
621
|
}, O = (r) => {
|
|
523
|
-
const e = r.get("$widget"), { name: t, implementation: s } = r.get("$widget"),
|
|
524
|
-
return c && !a ? { chatWidget: c, mainWidget:
|
|
525
|
-
},
|
|
622
|
+
const e = r.get("$widget"), { name: t, implementation: s } = r.get("$widget"), i = t.indexOf("_contact") > -1 ? ae(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);
|
|
623
|
+
return c && !a ? { chatWidget: c, mainWidget: i, data: n } : { mainWidget: i, data: n };
|
|
624
|
+
}, ce = (r) => {
|
|
526
625
|
const { chatWidget: e } = O(r);
|
|
527
626
|
return !!e;
|
|
528
627
|
}, Q = (r, e, t) => {
|
|
529
|
-
const { mainWidget: s, data:
|
|
530
|
-
return
|
|
531
|
-
|
|
532
|
-
a.navigateToConversationIfActive(e.id).then(() =>
|
|
628
|
+
const { mainWidget: s, data: i, chatWidget: n } = O(r);
|
|
629
|
+
return n ? n.state === "activated" ? n.invoke("open").then(() => {
|
|
630
|
+
n.container.getAsync("conversation").then((a) => {
|
|
631
|
+
a.navigateToConversationIfActive(e.id).then(() => L(r));
|
|
533
632
|
});
|
|
534
|
-
}) :
|
|
535
|
-
const { trigger: a } =
|
|
536
|
-
return a.action = "hide",
|
|
537
|
-
data:
|
|
633
|
+
}) : n.activate().then(() => {
|
|
634
|
+
const { trigger: a } = n.container.get("$settings");
|
|
635
|
+
return a.action = "hide", n.invoke("setSettings", () => ({
|
|
636
|
+
data: i,
|
|
538
637
|
trigger: a,
|
|
539
638
|
activate: !0
|
|
540
|
-
})).then(() =>
|
|
639
|
+
})).then(() => n.container.getAsync("components").then((o) => {
|
|
541
640
|
const c = o.components().ofType("contact-method");
|
|
542
641
|
o.write({
|
|
543
642
|
key: "setContactMethodId",
|
|
@@ -560,28 +659,28 @@ const oe = (r, e) => {
|
|
|
560
659
|
provider: "localStorage"
|
|
561
660
|
});
|
|
562
661
|
}));
|
|
563
|
-
}).then(() =>
|
|
662
|
+
}).then(() => n.invoke("attach", {
|
|
564
663
|
key: "contact-method",
|
|
565
664
|
triggerDOMElement: t,
|
|
566
665
|
withRenderState: "open"
|
|
567
|
-
})).then(() => (
|
|
568
|
-
|
|
666
|
+
})).then(() => (D(
|
|
667
|
+
n.container,
|
|
569
668
|
"activeStickyWidget",
|
|
570
|
-
|
|
669
|
+
N.Necessary,
|
|
571
670
|
{
|
|
572
|
-
medium:
|
|
671
|
+
medium: A.Local,
|
|
573
672
|
scope: V.Implementation
|
|
574
673
|
}
|
|
575
|
-
).then((a) => a(
|
|
576
|
-
a.setConversationEndedBehavior(
|
|
577
|
-
}).then(() =>
|
|
578
|
-
},
|
|
579
|
-
const { mainWidget: s, chatWidget:
|
|
580
|
-
return
|
|
581
|
-
|
|
582
|
-
}) : s.container.getAsync("conversation").then((
|
|
674
|
+
).then((a) => a(n.name)), n.container.getAsync("conversation").then((a) => {
|
|
675
|
+
a.setConversationEndedBehavior(E.Deactivate);
|
|
676
|
+
}).then(() => L(r)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(E.Navigate))), !n);
|
|
677
|
+
}, de = (r, e, t = "conversation") => {
|
|
678
|
+
const { mainWidget: s, chatWidget: i } = O(r);
|
|
679
|
+
return i ? i.container.getAsync("router").then((n) => {
|
|
680
|
+
n.navigate(t, { id: e.id });
|
|
681
|
+
}) : s.container.getAsync("conversation").then((n) => {
|
|
583
682
|
var a;
|
|
584
|
-
(a =
|
|
683
|
+
(a = n.setConversationEndedBehavior(E.Navigate)) == null || a.then(() => {
|
|
585
684
|
s.container.getAsync("router").then((o) => {
|
|
586
685
|
s.container.getAsync("components").then((c) => {
|
|
587
686
|
const h = c.components().ofType("conversation");
|
|
@@ -598,8 +697,8 @@ const oe = (r, e) => {
|
|
|
598
697
|
});
|
|
599
698
|
});
|
|
600
699
|
}, P = "conversations";
|
|
601
|
-
var
|
|
602
|
-
class
|
|
700
|
+
var E = /* @__PURE__ */ ((r) => (r.Deactivate = "deactivate", r.Navigate = "navigate", r.None = "none", r))(E || {});
|
|
701
|
+
class C {
|
|
603
702
|
constructor(e, t) {
|
|
604
703
|
d(this, "events");
|
|
605
704
|
d(this, "controllers", []);
|
|
@@ -615,21 +714,21 @@ class k {
|
|
|
615
714
|
this.events = s.events.createChild(this);
|
|
616
715
|
}
|
|
617
716
|
initialize() {
|
|
618
|
-
|
|
619
|
-
medium:
|
|
620
|
-
}).then((e) => this.storageWriter = e),
|
|
717
|
+
D(this.container, P, N.Necessary, {
|
|
718
|
+
medium: A.Local
|
|
719
|
+
}).then((e) => this.storageWriter = e), w(this.container, P, A.Local).then(
|
|
621
720
|
(e) => {
|
|
622
721
|
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
722
|
}
|
|
624
723
|
), this.container.getAsync("router").then((e) => this.router = e), this.events.subscribe("conversation:ended", (e, t) => {
|
|
625
|
-
var s,
|
|
724
|
+
var s, i, n;
|
|
626
725
|
switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
|
|
627
726
|
case "deactivate":
|
|
628
727
|
this.container.get("$widget").deactivate();
|
|
629
728
|
break;
|
|
630
729
|
case "navigate":
|
|
631
|
-
const o = (
|
|
632
|
-
o && ((
|
|
730
|
+
const o = (i = this.router) == null ? void 0 : i.getInitialRoute();
|
|
731
|
+
o && ((n = this.router) == null || n.navigate(o.name));
|
|
633
732
|
break;
|
|
634
733
|
}
|
|
635
734
|
this.writeToComponents({ active: !1 }), this.sessionInfo = null, this.storageWriter && this.storageWriter();
|
|
@@ -640,23 +739,23 @@ class k {
|
|
|
640
739
|
}
|
|
641
740
|
static getInstance(e, t = "conversation") {
|
|
642
741
|
return Y(e)(() => e.getAsync(t).then((s) => {
|
|
643
|
-
let
|
|
644
|
-
return
|
|
742
|
+
let i = s;
|
|
743
|
+
return i || K.getInstance(e).then((n) => (i = new C(e, n), i.initialize(), e.registerAsync(t, () => i), i));
|
|
645
744
|
}));
|
|
646
745
|
}
|
|
647
746
|
navigateToConversationIfActive(e) {
|
|
648
|
-
return
|
|
747
|
+
return w(this.container, P, A.Local).then(
|
|
649
748
|
(t) => {
|
|
650
749
|
var s;
|
|
651
750
|
if (t && t.id === e && t.route) {
|
|
652
|
-
const { name:
|
|
653
|
-
(s = this.router) == null || s.navigate(
|
|
751
|
+
const { name: i, params: n } = t.route;
|
|
752
|
+
(s = this.router) == null || s.navigate(i, n);
|
|
654
753
|
}
|
|
655
754
|
}
|
|
656
755
|
);
|
|
657
756
|
}
|
|
658
757
|
setConversationEndedBehavior(e) {
|
|
659
|
-
return
|
|
758
|
+
return w(this.container, P, A.Local).then(
|
|
660
759
|
(t) => {
|
|
661
760
|
let s = t;
|
|
662
761
|
return s ? s.conversationEndedBehavior = e : s = { conversationEndedBehavior: e }, this.sessionInfo = s, this.storageWriter && this.storageWriter(this.sessionInfo) || Promise.resolve();
|
|
@@ -665,12 +764,12 @@ class k {
|
|
|
665
764
|
}
|
|
666
765
|
createController(e, t) {
|
|
667
766
|
return v(this, null, function* () {
|
|
668
|
-
const s =
|
|
767
|
+
const s = F(e), { agents: i } = (yield w(
|
|
669
768
|
this.container,
|
|
670
769
|
s
|
|
671
|
-
)) || { agents: [] },
|
|
770
|
+
)) || { agents: [] }, n = this.controllers.findIndex((o) => o.conversation.id === e);
|
|
672
771
|
let a;
|
|
673
|
-
return
|
|
772
|
+
return n > -1 ? a = this.controllers[n].conversation : a = new oe(this.container, e, t), a.setInitialStorage({ agents: i || [] }), a;
|
|
674
773
|
});
|
|
675
774
|
}
|
|
676
775
|
registerProvider(e, t) {
|
|
@@ -678,18 +777,18 @@ class k {
|
|
|
678
777
|
name: e,
|
|
679
778
|
handler: t
|
|
680
779
|
};
|
|
681
|
-
this.providers.push(s), this.controllers.filter((
|
|
682
|
-
this.invokeHandler(s,
|
|
780
|
+
this.providers.push(s), this.controllers.filter((i) => i.conversation.providers.indexOf(e) > -1).forEach((i) => {
|
|
781
|
+
this.invokeHandler(s, i);
|
|
683
782
|
});
|
|
684
783
|
}
|
|
685
784
|
registerController(e, t) {
|
|
686
|
-
const s = this.controllers.findIndex((
|
|
687
|
-
let
|
|
785
|
+
const s = this.controllers.findIndex((n) => n.conversation.id === e.id);
|
|
786
|
+
let i;
|
|
688
787
|
if (s < 0) {
|
|
689
|
-
|
|
690
|
-
const
|
|
788
|
+
i = { conversation: e, component: t }, this.controllers.push(i);
|
|
789
|
+
const n = (a) => {
|
|
691
790
|
a && this.providers.filter((o) => a.indexOf(o.name) > -1).forEach((o) => {
|
|
692
|
-
this.invokeHandler(o,
|
|
791
|
+
this.invokeHandler(o, i);
|
|
693
792
|
});
|
|
694
793
|
};
|
|
695
794
|
return this.subscriptions.push(
|
|
@@ -701,10 +800,10 @@ class k {
|
|
|
701
800
|
e.onProvidersChange((a, o) => {
|
|
702
801
|
const { added: c, removed: h = [] } = o;
|
|
703
802
|
h.forEach((u) => {
|
|
704
|
-
(this.disposeProviders[u] || []).forEach((
|
|
705
|
-
|
|
803
|
+
(this.disposeProviders[u] || []).forEach((l) => {
|
|
804
|
+
l();
|
|
706
805
|
});
|
|
707
|
-
}),
|
|
806
|
+
}), n(c);
|
|
708
807
|
})
|
|
709
808
|
), this.subscriptions.push(
|
|
710
809
|
e.onStarted((a, o) => {
|
|
@@ -720,9 +819,9 @@ class k {
|
|
|
720
819
|
e.onUnreadMessage((a, o) => {
|
|
721
820
|
this.events.dispatch("conversation:unread-message", o), this.writeToComponents({ alert: { show: o } });
|
|
722
821
|
})
|
|
723
|
-
),
|
|
822
|
+
), n(e.providers), !0;
|
|
724
823
|
}
|
|
725
|
-
return
|
|
824
|
+
return i = this.controllers[s], !1;
|
|
726
825
|
}
|
|
727
826
|
writeToComponents(e, t = "conversationReturnButtonState") {
|
|
728
827
|
this.buttonQuery && this.components.write({
|
|
@@ -740,7 +839,7 @@ class k {
|
|
|
740
839
|
s && (this.disposeProviders[e.name] || (this.disposeProviders[e.name] = []), this.disposeProviders[e.name].push(s));
|
|
741
840
|
}
|
|
742
841
|
getComponentRoute() {
|
|
743
|
-
return
|
|
842
|
+
return w(this.container, P, A.Local).then(
|
|
744
843
|
(e) => e == null ? void 0 : e.route
|
|
745
844
|
);
|
|
746
845
|
}
|
|
@@ -753,116 +852,116 @@ class k {
|
|
|
753
852
|
e();
|
|
754
853
|
}), this.controllers = [], this.providers = [];
|
|
755
854
|
}
|
|
756
|
-
static handleContactMethodClick(e, t, s,
|
|
855
|
+
static handleContactMethodClick(e, t, s, i) {
|
|
757
856
|
return v(this, null, function* () {
|
|
758
|
-
if (
|
|
857
|
+
if (ce(t)) {
|
|
759
858
|
e.preventDefault();
|
|
760
|
-
let
|
|
761
|
-
|
|
859
|
+
let n = document.getElementById("humany-dynamic-anchor");
|
|
860
|
+
n || (n = document.createElement("a"), n.setAttribute("href", "#"), n.id = "humany-dynamic-anchor", document.body.appendChild(n)), Q(t, s, n);
|
|
762
861
|
}
|
|
763
862
|
Q(t, s);
|
|
764
863
|
});
|
|
765
864
|
}
|
|
766
865
|
static handleContactMethodSubmit(e, t) {
|
|
767
866
|
return v(this, null, function* () {
|
|
768
|
-
var s,
|
|
769
|
-
return (
|
|
867
|
+
var s, i;
|
|
868
|
+
return (i = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && i.id ? W(
|
|
770
869
|
e,
|
|
771
870
|
t.body.form.meta.conversation.id,
|
|
772
871
|
t.clientName
|
|
773
|
-
) :
|
|
872
|
+
) : de(e, t);
|
|
774
873
|
});
|
|
775
874
|
}
|
|
776
875
|
}
|
|
777
|
-
const
|
|
876
|
+
const he = (r, e) => r.reduce((t, s, i) => {
|
|
778
877
|
var a, o;
|
|
779
|
-
const
|
|
780
|
-
content: [m(
|
|
878
|
+
const n = b(m({}, s), {
|
|
879
|
+
content: [b(m({}, s.content), { key: s.key })]
|
|
781
880
|
});
|
|
782
|
-
if (t.length > 0 && s.type !==
|
|
881
|
+
if (t.length > 0 && s.type !== S.System) {
|
|
783
882
|
const c = t[t.length - 1];
|
|
784
883
|
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(m(
|
|
884
|
+
return c.timestamp = s.timestamp, c.content.push(b(m({}, s.content), { key: s.key })), t;
|
|
786
885
|
}
|
|
787
|
-
return t.push(
|
|
788
|
-
}, []),
|
|
789
|
-
|
|
886
|
+
return t.push(n), t;
|
|
887
|
+
}, []), we = (r) => Promise.all([
|
|
888
|
+
C.getInstance(r),
|
|
790
889
|
r.getAsync("router")
|
|
791
|
-
]).then(([e, t]) =>
|
|
890
|
+
]).then(([e, t]) => q(
|
|
792
891
|
r,
|
|
793
892
|
"conversation",
|
|
794
|
-
import("./conversation.
|
|
893
|
+
import("./conversation.d6cacfa5.js"),
|
|
795
894
|
(s) => v(void 0, null, function* () {
|
|
796
|
-
const { rehydrate:
|
|
797
|
-
const { providers:
|
|
798
|
-
if (
|
|
799
|
-
const y = Array.isArray(
|
|
895
|
+
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), h = 3 * 60 * 1e3, u = (g) => {
|
|
896
|
+
const { providers: p = [] } = g;
|
|
897
|
+
if (p) {
|
|
898
|
+
const y = Array.isArray(p) ? p : [p];
|
|
800
899
|
return o.setProviders(y), y;
|
|
801
900
|
}
|
|
802
901
|
};
|
|
803
902
|
u(s.properties(u)), o.setComponentMountedState(!0);
|
|
804
|
-
const
|
|
805
|
-
const { loading:
|
|
903
|
+
const l = (g) => {
|
|
904
|
+
const { loading: p, typingActors: y, messages: k } = g;
|
|
806
905
|
s.writeProperties({
|
|
807
|
-
loading:
|
|
906
|
+
loading: p,
|
|
808
907
|
typingActors: y,
|
|
809
|
-
messages:
|
|
908
|
+
messages: he(k, h)
|
|
810
909
|
});
|
|
811
910
|
};
|
|
812
|
-
|
|
813
|
-
if (
|
|
814
|
-
const { preventDefault: y, validationPromise:
|
|
911
|
+
l(o.getMessageStream()), c && (s.writeProperties({ conversationControllerId: o.id }), s.actions.create("user-submit", (g, p) => {
|
|
912
|
+
if (p) {
|
|
913
|
+
const { preventDefault: y, validationPromise: k } = p;
|
|
815
914
|
if (y) {
|
|
816
|
-
|
|
817
|
-
|
|
915
|
+
k && k().then((H) => {
|
|
916
|
+
H && o.user.print(H);
|
|
818
917
|
});
|
|
819
918
|
return;
|
|
820
919
|
}
|
|
821
920
|
}
|
|
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", (
|
|
921
|
+
o.user.print(g.text);
|
|
922
|
+
}), s.actions.create("user-typing", (g, p) => {
|
|
923
|
+
}), s.actions.create("form", (g, p) => {
|
|
924
|
+
}), s.actions.create("action", (g, p) => {
|
|
925
|
+
}), s.actions.create("overlay-mounted", (g, p) => {
|
|
926
|
+
}), s.actions.create("show-overlay", (g, p) => {
|
|
828
927
|
s.writeProperties({
|
|
829
928
|
overlay: { conversation: !1, secondary: !1 }
|
|
830
929
|
});
|
|
831
|
-
}), s.actions.create("hide-overlay", (
|
|
930
|
+
}), s.actions.create("hide-overlay", (g, p) => {
|
|
832
931
|
s.writeProperties({
|
|
833
932
|
overlay: null
|
|
834
933
|
});
|
|
835
|
-
}), s.actions.create("show-overlay-conversation", (
|
|
934
|
+
}), s.actions.create("show-overlay-conversation", (g, p) => {
|
|
836
935
|
s.writeProperties({
|
|
837
936
|
overlay: { conversation: !0, secondary: !1 }
|
|
838
937
|
});
|
|
839
|
-
}), s.actions.create("hide-overlay-conversation", (
|
|
938
|
+
}), s.actions.create("hide-overlay-conversation", (g, p) => {
|
|
840
939
|
s.writeProperties({
|
|
841
940
|
overlay: { conversation: !1, secondary: !1 }
|
|
842
941
|
});
|
|
843
942
|
}));
|
|
844
|
-
const
|
|
943
|
+
const f = o.events.subscribe(
|
|
845
944
|
"conversation:updated",
|
|
846
|
-
(
|
|
847
|
-
|
|
945
|
+
(g, p) => {
|
|
946
|
+
l(p);
|
|
848
947
|
}
|
|
849
948
|
);
|
|
850
949
|
return () => {
|
|
851
|
-
o.setComponentMountedState(!1),
|
|
950
|
+
o.setComponentMountedState(!1), f(), o.active || l({ messages: [], typingActors: [], loading: !1 });
|
|
852
951
|
};
|
|
853
952
|
}),
|
|
854
953
|
{ reuseController: !0 }
|
|
855
|
-
)),
|
|
954
|
+
)), Ae = (r) => Promise.all([
|
|
856
955
|
K.getInstance(r),
|
|
857
|
-
|
|
956
|
+
C.getInstance(r),
|
|
858
957
|
r.getAsync("router")
|
|
859
958
|
]).then(
|
|
860
|
-
([e, t, s]) =>
|
|
959
|
+
([e, t, s]) => q(
|
|
861
960
|
r,
|
|
862
961
|
"conversation-return-button",
|
|
863
962
|
import("./return-button.fb63a16e.js"),
|
|
864
|
-
(
|
|
865
|
-
|
|
963
|
+
(i) => {
|
|
964
|
+
i.actions.create("toggle", (n = {}) => {
|
|
866
965
|
var a;
|
|
867
966
|
(a = t.getComponentRoute()) == null || a.then((o) => {
|
|
868
967
|
o && s.navigate(o.name, o.params);
|
|
@@ -871,9 +970,9 @@ const de = (r, e) => r.reduce((t, s, n) => {
|
|
|
871
970
|
}
|
|
872
971
|
)
|
|
873
972
|
);
|
|
874
|
-
var
|
|
973
|
+
var le = /* @__PURE__ */ ((r) => (r.LinkList = "link-list", r.Separator = "separator", r.ButtonList = "button-list", r.Text = "text", r.HTML = "html", r.VideoRequest = "video-request", r))(le || {});
|
|
875
974
|
const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) => v(void 0, null, function* () {
|
|
876
|
-
(yield
|
|
975
|
+
(yield C.getInstance(r)).addSubscription(
|
|
877
976
|
s.registerComponent(
|
|
878
977
|
e,
|
|
879
978
|
Z(() => t)
|
|
@@ -881,14 +980,14 @@ const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) => v(void 0, nu
|
|
|
881
980
|
);
|
|
882
981
|
}));
|
|
883
982
|
export {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
983
|
+
we as ConversationComponent,
|
|
984
|
+
oe as ConversationController,
|
|
985
|
+
E as ConversationEndedBehavior,
|
|
887
986
|
ne as ConversationEntry,
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
987
|
+
le as ConversationMessageListItemType,
|
|
988
|
+
S as ConversationMessageType,
|
|
989
|
+
C as ConversationPlatform,
|
|
990
|
+
Ae as ConversationReturnButtonComponent,
|
|
892
991
|
Pe as registerCustomMessageComponent
|
|
893
992
|
};
|
|
894
993
|
//# sourceMappingURL=index.js.map
|