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