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