@telia-ace/widget-conversation 1.0.37 → 1.0.38-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 +45 -7
- package/dist/components/conversation/ui/message-list-items/item-list.d.ts +8 -0
- package/dist/{conversation.f80bcb4a.js → conversation.be64b43a.js} +331 -213
- package/dist/conversation.be64b43a.js.map +1 -0
- package/dist/index.js +140 -140
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +13 -1
- package/package.json +9 -9
- package/dist/conversation.f80bcb4a.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,42 +2,42 @@ var F = Object.defineProperty, G = Object.defineProperties;
|
|
|
2
2
|
var J = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var x = Object.getOwnPropertySymbols;
|
|
4
4
|
var $ = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var T = (
|
|
5
|
+
var T = (r, e, t) => e in r ? F(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
|
-
$.call(e, t) && T(
|
|
7
|
+
$.call(e, t) && T(r, t, e[t]);
|
|
8
8
|
if (x)
|
|
9
9
|
for (var t of x(e))
|
|
10
|
-
_.call(e, t) && T(
|
|
11
|
-
return
|
|
12
|
-
}, b = (
|
|
13
|
-
var B = (
|
|
10
|
+
_.call(e, t) && T(r, t, e[t]);
|
|
11
|
+
return r;
|
|
12
|
+
}, b = (r, e) => G(r, J(e));
|
|
13
|
+
var B = (r, e) => {
|
|
14
14
|
var t = {};
|
|
15
|
-
for (var s in
|
|
16
|
-
$.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var s of x(
|
|
19
|
-
e.indexOf(s) < 0 && _.call(
|
|
15
|
+
for (var s in r)
|
|
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 = (
|
|
23
|
-
var v = (
|
|
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
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
36
|
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, a);
|
|
37
|
-
o((t = t.apply(
|
|
37
|
+
o((t = t.apply(r, e)).next());
|
|
38
38
|
});
|
|
39
39
|
import { ComponentPlatform as Q } from "@telia-ace/widget-core";
|
|
40
|
-
import { createStorageWriter as
|
|
40
|
+
import { createStorageWriter as M, StorageCategory as N, readStorage as w, StorageMedium as A, StorageScope as V } from "@telia-ace/widget-services";
|
|
41
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
43
|
import { closeAllModals as L } from "@telia-ace/widget-plugins";
|
|
@@ -48,18 +48,18 @@ class ee {
|
|
|
48
48
|
d(this, "cache", /* @__PURE__ */ new Map());
|
|
49
49
|
d(this, "subscriptions", []);
|
|
50
50
|
this.controller = e;
|
|
51
|
-
const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (
|
|
51
|
+
const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (i, n) => {
|
|
52
52
|
n.type === "contact-method" && this.cache.set(n.response.id, n.response);
|
|
53
53
|
});
|
|
54
54
|
this.subscriptions.push(s);
|
|
55
55
|
}
|
|
56
56
|
getConversationLogs() {
|
|
57
57
|
return this.controller.messages.reduce((t, s) => {
|
|
58
|
-
const
|
|
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
59
|
return u && t.push(u), t;
|
|
60
60
|
}, []);
|
|
61
61
|
}
|
|
62
|
-
parseEntry(e, t, s,
|
|
62
|
+
parseEntry(e, t, s, i) {
|
|
63
63
|
const n = (h) => {
|
|
64
64
|
let u = [], l = [], f;
|
|
65
65
|
if (Array.isArray(h)) {
|
|
@@ -89,7 +89,7 @@ class ee {
|
|
|
89
89
|
`) : void 0,
|
|
90
90
|
source: this.createMessageSource(t),
|
|
91
91
|
alias: this.createAlias(t, s),
|
|
92
|
-
timestamp:
|
|
92
|
+
timestamp: i
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
createMessageSource(e) {
|
|
@@ -108,13 +108,13 @@ class ee {
|
|
|
108
108
|
getDetails(e, t = !0) {
|
|
109
109
|
if (!e)
|
|
110
110
|
return "";
|
|
111
|
-
const { header: s, title:
|
|
111
|
+
const { header: s, title: i, label: n, description: a, text: o, html: c, body: h, contactMethodId: u } = e;
|
|
112
112
|
let l = "";
|
|
113
113
|
if (u) {
|
|
114
114
|
const f = this.handleContactMethod(u.toString());
|
|
115
115
|
f && (l = this.appendText(l, f, t));
|
|
116
116
|
}
|
|
117
|
-
return s && (l = this.appendText(l, s, t)),
|
|
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
118
|
}
|
|
119
119
|
createMessageContent(e) {
|
|
120
120
|
let t = "";
|
|
@@ -122,10 +122,10 @@ class ee {
|
|
|
122
122
|
}
|
|
123
123
|
createMessageOptions(e) {
|
|
124
124
|
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:
|
|
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(([i, n]) => ({
|
|
126
|
+
actionKey: i,
|
|
127
127
|
label: n
|
|
128
|
-
}))), s.length && (t = s.map((
|
|
128
|
+
}))), s.length && (t = s.map((i) => this.getDetails(i, !1))), t;
|
|
129
129
|
}
|
|
130
130
|
appendText(e, t, s = !0) {
|
|
131
131
|
return s && e.length ? `${e}
|
|
@@ -137,7 +137,7 @@ ${t}` : e.length ? `${e} ${t}` : t;
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class
|
|
140
|
+
class W {
|
|
141
141
|
constructor(e, t) {
|
|
142
142
|
d(this, "id");
|
|
143
143
|
d(this, "name");
|
|
@@ -147,22 +147,22 @@ class M {
|
|
|
147
147
|
name: this.name,
|
|
148
148
|
avatar: this.avatar,
|
|
149
149
|
id: this.id
|
|
150
|
-
},
|
|
150
|
+
}, i = I(e, t);
|
|
151
151
|
return this.provider.createEntry(
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
i.key,
|
|
153
|
+
i.content,
|
|
154
154
|
S.Agent,
|
|
155
155
|
s,
|
|
156
|
-
|
|
156
|
+
i.timestamp
|
|
157
157
|
);
|
|
158
158
|
});
|
|
159
159
|
d(this, "typing", () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }));
|
|
160
160
|
this.provider = e, this.id = t.id || U(), this.name = t.name, this.avatar = t.avatar;
|
|
161
161
|
}
|
|
162
162
|
update(e) {
|
|
163
|
-
var
|
|
163
|
+
var i;
|
|
164
164
|
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), (
|
|
165
|
+
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", {
|
|
166
166
|
agent: this
|
|
167
167
|
});
|
|
168
168
|
}
|
|
@@ -182,10 +182,10 @@ class O {
|
|
|
182
182
|
createAgent(e = {}) {
|
|
183
183
|
var t;
|
|
184
184
|
if (this.controller) {
|
|
185
|
-
const s = this.controller.getAgentById(e.id),
|
|
185
|
+
const s = this.controller.getAgentById(e.id), i = s ? new W(this, m(m({}, s), e)) : new W(this, e);
|
|
186
186
|
return s || (t = this.controller) == null || t.events.dispatch("conversation:agent-created", {
|
|
187
|
-
agent:
|
|
188
|
-
}),
|
|
187
|
+
agent: i
|
|
188
|
+
}), i;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
print(e) {
|
|
@@ -200,9 +200,9 @@ class O {
|
|
|
200
200
|
return this.controller ? this.controller.loader() : () => () => {
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
createEntry(e, t, s,
|
|
203
|
+
createEntry(e, t, s, i, n) {
|
|
204
204
|
var a;
|
|
205
|
-
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s,
|
|
205
|
+
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, i, n);
|
|
206
206
|
}
|
|
207
207
|
dispose() {
|
|
208
208
|
var e;
|
|
@@ -245,7 +245,7 @@ class O {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
const j = (
|
|
248
|
+
const j = (r) => `conversation-${r}`;
|
|
249
249
|
class te {
|
|
250
250
|
constructor() {
|
|
251
251
|
d(this, "_locking", Promise.resolve());
|
|
@@ -257,8 +257,8 @@ class te {
|
|
|
257
257
|
lock() {
|
|
258
258
|
this._locks += 1;
|
|
259
259
|
let e, t = new Promise(
|
|
260
|
-
(
|
|
261
|
-
this._locks -= 1,
|
|
260
|
+
(i) => e = () => {
|
|
261
|
+
this._locks -= 1, i();
|
|
262
262
|
}
|
|
263
263
|
), s = this._locking.then(() => e);
|
|
264
264
|
return this._locking = this._locking.then(() => t), s;
|
|
@@ -272,9 +272,9 @@ class se {
|
|
|
272
272
|
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey = j(t.id), t.onStarted(() => v(this, null, function* () {
|
|
273
273
|
if (t.messages.length > 0)
|
|
274
274
|
return;
|
|
275
|
-
const { agents:
|
|
276
|
-
|
|
277
|
-
const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new
|
|
275
|
+
const { agents: i } = yield this.read(), n = [];
|
|
276
|
+
i && i.forEach((o) => {
|
|
277
|
+
const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new W(h, { name: o.name, avatar: o.avatar, id: o.id });
|
|
278
278
|
n.push(u);
|
|
279
279
|
});
|
|
280
280
|
const { messages: a } = yield this.read();
|
|
@@ -301,9 +301,9 @@ class se {
|
|
|
301
301
|
t.print(o.content.items || o.content);
|
|
302
302
|
}
|
|
303
303
|
});
|
|
304
|
-
})), t.onMessageCreated((
|
|
304
|
+
})), t.onMessageCreated((i, n) => v(this, null, function* () {
|
|
305
305
|
this.write(n.message, "messages");
|
|
306
|
-
})), t.events.subscribe("conversation:agent-created", (
|
|
306
|
+
})), t.events.subscribe("conversation:agent-created", (i, n) => v(this, null, function* () {
|
|
307
307
|
const a = {
|
|
308
308
|
id: n.agent.id,
|
|
309
309
|
name: n.agent.name,
|
|
@@ -311,7 +311,7 @@ class se {
|
|
|
311
311
|
providerName: n.agent.provider.name
|
|
312
312
|
};
|
|
313
313
|
yield this.write(a, "agents");
|
|
314
|
-
})), t.events.subscribe("conversation:agent-updated", (
|
|
314
|
+
})), t.events.subscribe("conversation:agent-updated", (i, n) => v(this, null, function* () {
|
|
315
315
|
const { agents: a } = yield this.read();
|
|
316
316
|
yield this.write(
|
|
317
317
|
[
|
|
@@ -342,8 +342,8 @@ class se {
|
|
|
342
342
|
return v(this, null, function* () {
|
|
343
343
|
if (!this.enabled)
|
|
344
344
|
return;
|
|
345
|
-
const
|
|
346
|
-
return
|
|
345
|
+
const i = yield this.locker.lock();
|
|
346
|
+
return M(
|
|
347
347
|
this.container,
|
|
348
348
|
this.sessionStorageKey,
|
|
349
349
|
N.Necessary
|
|
@@ -351,12 +351,12 @@ class se {
|
|
|
351
351
|
if (s === "add") {
|
|
352
352
|
const a = yield this.read();
|
|
353
353
|
if (t === "messages" && a.messages.findIndex((c) => c.key === e.key) > -1) {
|
|
354
|
-
|
|
354
|
+
i();
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
let o = m({}, a);
|
|
358
358
|
return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]), n(m(m({}, a), o)).then(() => {
|
|
359
|
-
|
|
359
|
+
i();
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
362
|
if (s === "update" && t === "agents") {
|
|
@@ -364,11 +364,11 @@ class se {
|
|
|
364
364
|
return n(b(m({}, a), {
|
|
365
365
|
agents: e
|
|
366
366
|
})).then(() => {
|
|
367
|
-
|
|
367
|
+
i();
|
|
368
368
|
});
|
|
369
369
|
}
|
|
370
370
|
return n(e).then(() => {
|
|
371
|
-
|
|
371
|
+
i();
|
|
372
372
|
});
|
|
373
373
|
}));
|
|
374
374
|
});
|
|
@@ -398,15 +398,15 @@ class ie {
|
|
|
398
398
|
this.controller = e;
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
const
|
|
402
|
-
const s = yield
|
|
401
|
+
const D = (r, e, t) => v(void 0, null, function* () {
|
|
402
|
+
const s = yield r.getAsync("conversation"), i = yield r.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
|
|
403
403
|
if (n) {
|
|
404
404
|
const a = [...n.conversation.providers];
|
|
405
405
|
a.forEach((c) => {
|
|
406
406
|
n.conversation.setProviderOptions(c, { silent: !0 });
|
|
407
407
|
}), n.conversation.queueProviders(a), n.conversation.setProviders([t]);
|
|
408
|
-
const o =
|
|
409
|
-
|
|
408
|
+
const o = i.components().ofType("conversation");
|
|
409
|
+
i.write({
|
|
410
410
|
key: "setConversationProvider",
|
|
411
411
|
attributes: {
|
|
412
412
|
properties: { providers: [t] }
|
|
@@ -431,35 +431,35 @@ class ne {
|
|
|
431
431
|
return typeof e == "string" ? { body: e } : e.length > -1 && typeof e == "object" ? { items: e } : e;
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
var S = /* @__PURE__ */ ((
|
|
435
|
-
const I = (
|
|
436
|
-
let t, s = (e == null ? void 0 : e.key) || U(),
|
|
437
|
-
if (Array.isArray(
|
|
438
|
-
typeof
|
|
439
|
-
else if (typeof
|
|
440
|
-
t = { body:
|
|
441
|
-
else if (
|
|
442
|
-
t = m({},
|
|
434
|
+
var S = /* @__PURE__ */ ((r) => (r.User = "user", r.Agent = "agent", r.System = "system", r))(S || {});
|
|
435
|
+
const I = (r, e) => {
|
|
436
|
+
let t, s = (e == null ? void 0 : e.key) || U(), i = Date.now();
|
|
437
|
+
if (Array.isArray(r) && r.length > -1)
|
|
438
|
+
typeof r[0] == "string" ? t = { items: [r] } : t = { items: r };
|
|
439
|
+
else if (typeof r == "string")
|
|
440
|
+
t = { body: r };
|
|
441
|
+
else if (r = r || {}, r.type)
|
|
442
|
+
t = m({}, r);
|
|
443
443
|
else {
|
|
444
444
|
if (t = {
|
|
445
|
-
body:
|
|
446
|
-
actions:
|
|
447
|
-
title:
|
|
448
|
-
},
|
|
445
|
+
body: r.body,
|
|
446
|
+
actions: r.actions,
|
|
447
|
+
title: r.title
|
|
448
|
+
}, r.key && (s = r.key), r.timestamp && (i = r.timestamp), typeof r.form == "function") {
|
|
449
449
|
const n = X.create(s);
|
|
450
|
-
|
|
450
|
+
r.form(n);
|
|
451
451
|
const a = n.get();
|
|
452
452
|
t.form = a;
|
|
453
453
|
}
|
|
454
|
-
|
|
454
|
+
r.timestamp === null && (i = null);
|
|
455
455
|
}
|
|
456
|
-
return { content: t, key: s, timestamp:
|
|
457
|
-
}, z = (
|
|
456
|
+
return { content: t, key: s, timestamp: i };
|
|
457
|
+
}, z = (r, e) => {
|
|
458
458
|
if (!e)
|
|
459
459
|
return;
|
|
460
|
-
const t = JSON.stringify(e), s =
|
|
460
|
+
const t = JSON.stringify(e), s = r.findIndex((i) => t === JSON.stringify(i));
|
|
461
461
|
if (s > -1)
|
|
462
|
-
return
|
|
462
|
+
return r.splice(s, 1);
|
|
463
463
|
};
|
|
464
464
|
class oe {
|
|
465
465
|
constructor(e, t, s) {
|
|
@@ -487,19 +487,19 @@ class oe {
|
|
|
487
487
|
);
|
|
488
488
|
});
|
|
489
489
|
this.container = e, this.id = t;
|
|
490
|
-
const
|
|
491
|
-
this.events =
|
|
490
|
+
const i = e.get("$widget");
|
|
491
|
+
this.events = i.events.createChild(this), this.store = new re(e, this, s.rehydrate), this.conversationHistory = new ee(this);
|
|
492
492
|
}
|
|
493
493
|
setInitialStorage(e) {
|
|
494
494
|
this.store.setInitialData(e);
|
|
495
495
|
}
|
|
496
496
|
setProviders(e) {
|
|
497
497
|
const t = [], s = [];
|
|
498
|
-
this.providers.reduce((
|
|
499
|
-
const n = this.providers.indexOf(
|
|
500
|
-
n > -1 && (t.push(
|
|
501
|
-
}), e.forEach((
|
|
502
|
-
this.providers.indexOf(
|
|
498
|
+
this.providers.reduce((i, n) => (e.indexOf(n) === -1 && i.push(n), i), []).forEach((i) => {
|
|
499
|
+
const n = this.providers.indexOf(i);
|
|
500
|
+
n > -1 && (t.push(i), this.providers.splice(n, 1));
|
|
501
|
+
}), e.forEach((i) => {
|
|
502
|
+
this.providers.indexOf(i) === -1 && (s.push(i), this.providers.push(i));
|
|
503
503
|
}), (s.length || t.length) && this.events.dispatch("conversation:providers-changed", { added: s, removed: t });
|
|
504
504
|
}
|
|
505
505
|
createProvider(e) {
|
|
@@ -546,14 +546,14 @@ class oe {
|
|
|
546
546
|
s > -1 && this.registeredProviders[s].setOptions(t);
|
|
547
547
|
}
|
|
548
548
|
changeProvider(e) {
|
|
549
|
-
this.registeredProviders.find((s) => s.name === e) &&
|
|
549
|
+
this.registeredProviders.find((s) => s.name === e) && D(this.container, this.id, e);
|
|
550
550
|
}
|
|
551
551
|
queueProviders(e) {
|
|
552
552
|
this.queuedProviders = e;
|
|
553
553
|
}
|
|
554
554
|
onCompleteProvider() {
|
|
555
555
|
const e = this.queuedProviders.pop();
|
|
556
|
-
e &&
|
|
556
|
+
e && D(this.container, this.id, e);
|
|
557
557
|
}
|
|
558
558
|
getComponentMountedState() {
|
|
559
559
|
return this.componentMounted;
|
|
@@ -561,15 +561,15 @@ class oe {
|
|
|
561
561
|
onUnreadMessage(e) {
|
|
562
562
|
return this.events.subscribe("conversation:unread-message", e);
|
|
563
563
|
}
|
|
564
|
-
createEntry(e, t, s,
|
|
564
|
+
createEntry(e, t, s, i, n) {
|
|
565
565
|
const a = {
|
|
566
566
|
key: e,
|
|
567
567
|
content: t,
|
|
568
568
|
type: s,
|
|
569
|
-
sender:
|
|
569
|
+
sender: i || null,
|
|
570
570
|
timestamp: n || n === null ? n : Date.now()
|
|
571
571
|
};
|
|
572
|
-
this.messages.push(a), a.type === "agent" && z(this.typingActors,
|
|
572
|
+
this.messages.push(a), a.type === "agent" && z(this.typingActors, i);
|
|
573
573
|
const o = new ne((c) => {
|
|
574
574
|
if (c !== null) {
|
|
575
575
|
const h = c, { timestamp: u = void 0 } = h, l = B(h, ["timestamp"]);
|
|
@@ -618,25 +618,25 @@ class oe {
|
|
|
618
618
|
return this.conversationHistory.getConversationLogs();
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
const ae = (
|
|
622
|
-
const t =
|
|
621
|
+
const ae = (r, e) => {
|
|
622
|
+
const t = r.split("_contact");
|
|
623
623
|
return e.widgets.get(t[0]);
|
|
624
|
-
}, R = (
|
|
625
|
-
const e =
|
|
626
|
-
return c && !a ? { chatWidget: c, mainWidget:
|
|
627
|
-
}, ce = (
|
|
628
|
-
const { chatWidget: e } = R(
|
|
624
|
+
}, R = (r) => {
|
|
625
|
+
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);
|
|
626
|
+
return c && !a ? { chatWidget: c, mainWidget: i, data: n } : { mainWidget: i, data: n };
|
|
627
|
+
}, ce = (r) => {
|
|
628
|
+
const { chatWidget: e } = R(r);
|
|
629
629
|
return !!e;
|
|
630
|
-
}, K = (
|
|
631
|
-
const { mainWidget: s, data:
|
|
630
|
+
}, K = (r, e, t) => {
|
|
631
|
+
const { mainWidget: s, data: i, chatWidget: n } = R(r);
|
|
632
632
|
return n ? n.state === "activated" ? n.invoke("open").then(() => {
|
|
633
633
|
n.container.getAsync("conversation").then((a) => {
|
|
634
|
-
a.navigateToConversationIfActive(e.id).then(() => L(
|
|
634
|
+
a.navigateToConversationIfActive(e.id).then(() => L(r));
|
|
635
635
|
});
|
|
636
636
|
}) : n.activate().then(() => {
|
|
637
637
|
const { trigger: a } = n.container.get("$settings");
|
|
638
638
|
return a.action = "hide", n.invoke("setSettings", () => ({
|
|
639
|
-
data:
|
|
639
|
+
data: i,
|
|
640
640
|
trigger: a,
|
|
641
641
|
activate: !0
|
|
642
642
|
})).then(() => n.container.getAsync("components").then((o) => {
|
|
@@ -666,7 +666,7 @@ const ae = (i, e) => {
|
|
|
666
666
|
key: "contact-method",
|
|
667
667
|
triggerDOMElement: t,
|
|
668
668
|
withRenderState: "open"
|
|
669
|
-
})).then(() => (
|
|
669
|
+
})).then(() => (M(
|
|
670
670
|
n.container,
|
|
671
671
|
"activeStickyWidget",
|
|
672
672
|
N.Necessary,
|
|
@@ -676,10 +676,10 @@ const ae = (i, e) => {
|
|
|
676
676
|
}
|
|
677
677
|
).then((a) => a(n.name)), n.container.getAsync("conversation").then((a) => {
|
|
678
678
|
a.setConversationEndedBehavior(E.Deactivate);
|
|
679
|
-
}).then(() => L(
|
|
680
|
-
}, de = (
|
|
681
|
-
const { mainWidget: s, chatWidget:
|
|
682
|
-
return
|
|
679
|
+
}).then(() => L(r)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(E.Navigate))), !n);
|
|
680
|
+
}, de = (r, e, t = "conversation") => {
|
|
681
|
+
const { mainWidget: s, chatWidget: i } = R(r);
|
|
682
|
+
return i ? i.container.getAsync("router").then((n) => {
|
|
683
683
|
n.navigate(t, { id: e.id });
|
|
684
684
|
}) : s.container.getAsync("conversation").then((n) => {
|
|
685
685
|
var a;
|
|
@@ -700,7 +700,7 @@ const ae = (i, e) => {
|
|
|
700
700
|
});
|
|
701
701
|
});
|
|
702
702
|
}, P = "conversations";
|
|
703
|
-
var E = /* @__PURE__ */ ((
|
|
703
|
+
var E = /* @__PURE__ */ ((r) => (r.Deactivate = "deactivate", r.Navigate = "navigate", r.None = "none", r))(E || {});
|
|
704
704
|
class C {
|
|
705
705
|
constructor(e, t) {
|
|
706
706
|
d(this, "events");
|
|
@@ -717,20 +717,20 @@ class C {
|
|
|
717
717
|
this.events = s.events.createChild(this);
|
|
718
718
|
}
|
|
719
719
|
initialize() {
|
|
720
|
-
|
|
720
|
+
M(this.container, P, N.Necessary, {
|
|
721
721
|
medium: A.Local
|
|
722
722
|
}).then((e) => this.storageWriter = e), w(this.container, P, A.Local).then(
|
|
723
723
|
(e) => {
|
|
724
724
|
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
725
|
}
|
|
726
726
|
), this.container.getAsync("router").then((e) => this.router = e), this.events.subscribe("conversation:ended", (e, t) => {
|
|
727
|
-
var s,
|
|
727
|
+
var s, i, n;
|
|
728
728
|
switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
|
|
729
729
|
case "deactivate":
|
|
730
730
|
this.container.get("$widget").deactivate();
|
|
731
731
|
break;
|
|
732
732
|
case "navigate":
|
|
733
|
-
const o = (
|
|
733
|
+
const o = (i = this.router) == null ? void 0 : i.getInitialRoute();
|
|
734
734
|
o && ((n = this.router) == null || n.navigate(o.name));
|
|
735
735
|
break;
|
|
736
736
|
}
|
|
@@ -742,8 +742,8 @@ class C {
|
|
|
742
742
|
}
|
|
743
743
|
static getInstance(e, t = "conversation") {
|
|
744
744
|
return Y(e)(() => e.getAsync(t).then((s) => {
|
|
745
|
-
let
|
|
746
|
-
return
|
|
745
|
+
let i = s;
|
|
746
|
+
return i || Q.getInstance(e).then((n) => (i = new C(e, n), i.initialize(), e.registerAsync(t, () => i), i));
|
|
747
747
|
}));
|
|
748
748
|
}
|
|
749
749
|
navigateToConversationIfActive(e) {
|
|
@@ -751,8 +751,8 @@ class C {
|
|
|
751
751
|
(t) => {
|
|
752
752
|
var s;
|
|
753
753
|
if (t && t.id === e && t.route) {
|
|
754
|
-
const { name:
|
|
755
|
-
(s = this.router) == null || s.navigate(
|
|
754
|
+
const { name: i, params: n } = t.route;
|
|
755
|
+
(s = this.router) == null || s.navigate(i, n);
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
);
|
|
@@ -767,12 +767,12 @@ class C {
|
|
|
767
767
|
}
|
|
768
768
|
createController(e, t) {
|
|
769
769
|
return v(this, null, function* () {
|
|
770
|
-
const s = j(e), { agents:
|
|
770
|
+
const s = j(e), { agents: i } = (yield w(
|
|
771
771
|
this.container,
|
|
772
772
|
s
|
|
773
773
|
)) || { agents: [] }, n = this.controllers.findIndex((o) => o.conversation.id === e);
|
|
774
774
|
let a;
|
|
775
|
-
return n > -1 ? a = this.controllers[n].conversation : a = new oe(this.container, e, t), a.setInitialStorage({ agents:
|
|
775
|
+
return n > -1 ? a = this.controllers[n].conversation : a = new oe(this.container, e, t), a.setInitialStorage({ agents: i || [] }), a;
|
|
776
776
|
});
|
|
777
777
|
}
|
|
778
778
|
registerProvider(e, t) {
|
|
@@ -780,18 +780,18 @@ class C {
|
|
|
780
780
|
name: e,
|
|
781
781
|
handler: t
|
|
782
782
|
};
|
|
783
|
-
this.providers.push(s), this.controllers.filter((
|
|
784
|
-
this.invokeHandler(s,
|
|
783
|
+
this.providers.push(s), this.controllers.filter((i) => i.conversation.providers.indexOf(e) > -1).forEach((i) => {
|
|
784
|
+
this.invokeHandler(s, i);
|
|
785
785
|
});
|
|
786
786
|
}
|
|
787
787
|
registerController(e, t) {
|
|
788
788
|
const s = this.controllers.findIndex((n) => n.conversation.id === e.id);
|
|
789
|
-
let
|
|
789
|
+
let i;
|
|
790
790
|
if (s < 0) {
|
|
791
|
-
|
|
791
|
+
i = { conversation: e, component: t }, this.controllers.push(i);
|
|
792
792
|
const n = (a) => {
|
|
793
793
|
a && this.providers.filter((o) => a.indexOf(o.name) > -1).forEach((o) => {
|
|
794
|
-
this.invokeHandler(o,
|
|
794
|
+
this.invokeHandler(o, i);
|
|
795
795
|
});
|
|
796
796
|
};
|
|
797
797
|
return this.subscriptions.push(
|
|
@@ -824,7 +824,7 @@ class C {
|
|
|
824
824
|
})
|
|
825
825
|
), n(e.providers), !0;
|
|
826
826
|
}
|
|
827
|
-
return
|
|
827
|
+
return i = this.controllers[s], !1;
|
|
828
828
|
}
|
|
829
829
|
writeToComponents(e, t = "conversationReturnButtonState") {
|
|
830
830
|
this.buttonQuery && this.components.write({
|
|
@@ -855,7 +855,7 @@ class C {
|
|
|
855
855
|
e();
|
|
856
856
|
}), this.controllers = [], this.providers = [];
|
|
857
857
|
}
|
|
858
|
-
static handleContactMethodClick(e, t, s,
|
|
858
|
+
static handleContactMethodClick(e, t, s, i) {
|
|
859
859
|
return v(this, null, function* () {
|
|
860
860
|
if (ce(t)) {
|
|
861
861
|
e.preventDefault();
|
|
@@ -867,8 +867,8 @@ class C {
|
|
|
867
867
|
}
|
|
868
868
|
static handleContactMethodSubmit(e, t) {
|
|
869
869
|
return v(this, null, function* () {
|
|
870
|
-
var s,
|
|
871
|
-
return (
|
|
870
|
+
var s, i;
|
|
871
|
+
return (i = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && i.id ? D(
|
|
872
872
|
e,
|
|
873
873
|
t.body.form.meta.conversation.id,
|
|
874
874
|
t.clientName
|
|
@@ -876,7 +876,7 @@ class C {
|
|
|
876
876
|
});
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
|
-
const he = (
|
|
879
|
+
const he = (r, e) => r.reduce((t, s, i) => {
|
|
880
880
|
var a, o;
|
|
881
881
|
const n = b(m({}, s), {
|
|
882
882
|
content: [b(m({}, s.content), { key: s.key })]
|
|
@@ -887,15 +887,15 @@ const he = (i, e) => i.reduce((t, s, r) => {
|
|
|
887
887
|
return c.timestamp = s.timestamp, c.content.push(b(m({}, s.content), { key: s.key })), t;
|
|
888
888
|
}
|
|
889
889
|
return t.push(n), t;
|
|
890
|
-
}, []), we = (
|
|
891
|
-
C.getInstance(
|
|
892
|
-
|
|
890
|
+
}, []), we = (r) => Promise.all([
|
|
891
|
+
C.getInstance(r),
|
|
892
|
+
r.getAsync("router")
|
|
893
893
|
]).then(([e, t]) => q(
|
|
894
|
-
|
|
894
|
+
r,
|
|
895
895
|
"conversation",
|
|
896
|
-
import("./conversation.
|
|
896
|
+
import("./conversation.be64b43a.js"),
|
|
897
897
|
(s) => v(void 0, null, function* () {
|
|
898
|
-
const { rehydrate:
|
|
898
|
+
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) => {
|
|
899
899
|
const { providers: p = [] } = g;
|
|
900
900
|
if (p) {
|
|
901
901
|
const y = Array.isArray(p) ? p : [p];
|
|
@@ -954,17 +954,17 @@ const he = (i, e) => i.reduce((t, s, r) => {
|
|
|
954
954
|
};
|
|
955
955
|
}),
|
|
956
956
|
{ reuseController: !0 }
|
|
957
|
-
)), Ae = (
|
|
958
|
-
Q.getInstance(
|
|
959
|
-
C.getInstance(
|
|
960
|
-
|
|
957
|
+
)), Ae = (r) => Promise.all([
|
|
958
|
+
Q.getInstance(r),
|
|
959
|
+
C.getInstance(r),
|
|
960
|
+
r.getAsync("router")
|
|
961
961
|
]).then(
|
|
962
962
|
([e, t, s]) => q(
|
|
963
|
-
|
|
963
|
+
r,
|
|
964
964
|
"conversation-return-button",
|
|
965
965
|
import("./return-button.fb63a16e.js"),
|
|
966
|
-
(
|
|
967
|
-
|
|
966
|
+
(i) => {
|
|
967
|
+
i.actions.create("toggle", (n = {}) => {
|
|
968
968
|
var a;
|
|
969
969
|
(a = t.getComponentRoute()) == null || a.then((o) => {
|
|
970
970
|
o && s.navigate(o.name, o.params);
|
|
@@ -973,9 +973,9 @@ const he = (i, e) => i.reduce((t, s, r) => {
|
|
|
973
973
|
}
|
|
974
974
|
)
|
|
975
975
|
);
|
|
976
|
-
var le = /* @__PURE__ */ ((
|
|
977
|
-
const Pe = (
|
|
978
|
-
(yield C.getInstance(
|
|
976
|
+
var le = /* @__PURE__ */ ((r) => (r.LinkList = "link-list", r.Separator = "separator", r.ButtonList = "button-list", r.ItemList = "item-list", r.Text = "text", r.HTML = "html", r.VideoRequest = "video-request", r))(le || {});
|
|
977
|
+
const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) => v(void 0, null, function* () {
|
|
978
|
+
(yield C.getInstance(r)).addSubscription(
|
|
979
979
|
s.registerComponent(
|
|
980
980
|
e,
|
|
981
981
|
Z(() => t)
|