@telia-ace/widget-conversation 1.0.24 → 1.0.25
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 +110 -210
- package/dist/conversation.3981560b.js +1100 -0
- package/dist/conversation.3981560b.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +164 -182
- package/dist/index.js.map +1 -1
- package/dist/{return-button.facf6a45.js → return-button.8773c0de.js} +1 -1
- package/dist/return-button.8773c0de.js.map +1 -0
- package/dist/types.d.ts +41 -34
- package/dist/{components/conversation/plugin.d.ts → ui/conversation/conversation-component.d.ts} +2 -13
- package/dist/ui/conversation/conversation-content.d.ts +11 -0
- package/dist/{components/conversation/ui/input.d.ts → ui/conversation/conversation-input.d.ts} +0 -0
- package/dist/ui/conversation/conversation-loader.d.ts +8 -0
- package/dist/ui/conversation/conversation-message.d.ts +7 -0
- package/dist/ui/conversation/conversation-styles.d.ts +11 -0
- package/dist/{components → ui}/conversation/conversation.d.ts +0 -0
- package/dist/ui/conversation/index.d.ts +2 -0
- package/dist/{components/conversation/ui → ui/conversation}/message-types/agent.d.ts +1 -1
- package/dist/ui/conversation/message-types/custom.d.ts +9 -0
- package/dist/{components/conversation/ui → ui/conversation}/message-types/index.d.ts +1 -0
- package/dist/{components/conversation/ui → ui/conversation}/message-types/system.d.ts +0 -0
- package/dist/{components/conversation/ui → ui/conversation}/message-types/timestamp.d.ts +0 -0
- package/dist/{components/conversation/ui → ui/conversation}/message-types/user.d.ts +0 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/return-button/index.d.ts +2 -0
- package/dist/{components/return-button/plugin.d.ts → ui/return-button/return-button-component.d.ts} +2 -1
- package/dist/{components → ui}/return-button/return-button.d.ts +0 -0
- package/package.json +8 -8
- package/dist/components/conversation/ui/content.d.ts +0 -2
- package/dist/components/conversation/ui/loader.d.ts +0 -8
- package/dist/components/conversation/ui/message-list-items/button-list.d.ts +0 -8
- package/dist/components/conversation/ui/message-list-items/custom.d.ts +0 -9
- package/dist/components/conversation/ui/message-list-items/html.d.ts +0 -5
- package/dist/components/conversation/ui/message-list-items/link-list.d.ts +0 -8
- package/dist/components/conversation/ui/message-list-items/separator.d.ts +0 -2
- package/dist/components/conversation/ui/message-list-items/text.d.ts +0 -6
- package/dist/components/conversation/ui/message-list-items/video-request.d.ts +0 -8
- package/dist/components/conversation/ui/message-types/message-list.d.ts +0 -9
- package/dist/components/conversation/ui/message.d.ts +0 -7
- package/dist/components/conversation/ui/overlay-outlets.d.ts +0 -13
- package/dist/components/conversation/ui/styles.d.ts +0 -27
- package/dist/conversation.edf14596.js +0 -1191
- package/dist/conversation.edf14596.js.map +0 -1
- package/dist/return-button.facf6a45.js.map +0 -1
- package/dist/utils/map-actions.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
var U = Object.defineProperty,
|
|
1
|
+
var U = Object.defineProperty, F = Object.defineProperties;
|
|
2
2
|
var _ = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var C = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var T = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var N = (i, t, e) => t in i ? U(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, p = (i, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
7
|
+
T.call(t, e) && N(i, e, t[e]);
|
|
8
8
|
if (C)
|
|
9
9
|
for (var e of C(t))
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, g = (
|
|
13
|
-
var R = (
|
|
10
|
+
D.call(t, e) && N(i, e, t[e]);
|
|
11
|
+
return i;
|
|
12
|
+
}, g = (i, t) => F(i, _(t));
|
|
13
|
+
var R = (i, t) => {
|
|
14
14
|
var e = {};
|
|
15
|
-
for (var s in
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
for (var s of C(
|
|
19
|
-
t.indexOf(s) < 0 &&
|
|
15
|
+
for (var s in i)
|
|
16
|
+
T.call(i, s) && t.indexOf(s) < 0 && (e[s] = i[s]);
|
|
17
|
+
if (i != null && C)
|
|
18
|
+
for (var s of C(i))
|
|
19
|
+
t.indexOf(s) < 0 && D.call(i, s) && (e[s] = i[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
23
|
-
var
|
|
22
|
+
var S = (i, t, e) => new Promise((s, r) => {
|
|
23
|
+
var n = (c) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(c));
|
|
26
26
|
} catch (h) {
|
|
27
|
-
|
|
27
|
+
r(h);
|
|
28
28
|
}
|
|
29
29
|
}, o = (c) => {
|
|
30
30
|
try {
|
|
31
31
|
a(e.throw(c));
|
|
32
32
|
} catch (h) {
|
|
33
|
-
|
|
33
|
+
r(h);
|
|
34
34
|
}
|
|
35
|
-
}, a = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(
|
|
36
|
-
a((e = e.apply(
|
|
35
|
+
}, a = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, o);
|
|
36
|
+
a((e = e.apply(i, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ComponentPlatform as
|
|
39
|
-
import { createStorageWriter as
|
|
40
|
-
import { uuid as j, lock as
|
|
41
|
-
import { FormBuilder as
|
|
42
|
-
import { closeAllModals as
|
|
38
|
+
import { ComponentPlatform as H } from "@telia-ace/widget-core";
|
|
39
|
+
import { createStorageWriter as z, StorageCategory as $, StorageMedium as m, StorageScope as L, readStorage as A } from "@telia-ace/widget-services";
|
|
40
|
+
import { uuid as j, lock as G } from "@telia-ace/widget-utilities";
|
|
41
|
+
import { FormBuilder as J } from "@telia-ace/widget-forms";
|
|
42
|
+
import { closeAllModals as M } from "@telia-ace/widget-plugins";
|
|
43
43
|
import { createReactComponent as Q } from "@telia-ace/widget-ui";
|
|
44
|
-
import { lazy as
|
|
45
|
-
class
|
|
44
|
+
import { lazy as K } from "react";
|
|
45
|
+
class V {
|
|
46
46
|
constructor(t, e) {
|
|
47
47
|
this.provider = t, this.print = (s) => {
|
|
48
|
-
const
|
|
49
|
-
return this.provider.createEntry(
|
|
48
|
+
const r = { name: this.name, avatar: this.avatar }, n = x(s);
|
|
49
|
+
return this.provider.createEntry(n.key, n.content, E.Agent, r, n.timestamp);
|
|
50
50
|
}, this.typing = () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }), this.name = e.name, this.avatar = e.avatar;
|
|
51
51
|
}
|
|
52
52
|
update(t) {
|
|
@@ -63,7 +63,7 @@ class k {
|
|
|
63
63
|
}
|
|
64
64
|
createAgent(t = {}) {
|
|
65
65
|
if (this.controller)
|
|
66
|
-
return new
|
|
66
|
+
return new V(this, t);
|
|
67
67
|
}
|
|
68
68
|
print(t) {
|
|
69
69
|
var e;
|
|
@@ -77,9 +77,9 @@ class k {
|
|
|
77
77
|
return this.controller ? this.controller.loader() : () => () => {
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
createEntry(t, e, s,
|
|
80
|
+
createEntry(t, e, s, r, n) {
|
|
81
81
|
var o;
|
|
82
|
-
return (o = this.controller) == null ? void 0 : o.createEntry(t, e, s,
|
|
82
|
+
return (o = this.controller) == null ? void 0 : o.createEntry(t, e, s, r, n);
|
|
83
83
|
}
|
|
84
84
|
dispose() {
|
|
85
85
|
var t;
|
|
@@ -104,7 +104,7 @@ class k {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
class
|
|
107
|
+
class Y {
|
|
108
108
|
constructor(t) {
|
|
109
109
|
this.controller = t, this.print = (e) => {
|
|
110
110
|
const s = x(e);
|
|
@@ -112,7 +112,7 @@ class V {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
class
|
|
115
|
+
class q {
|
|
116
116
|
constructor(t) {
|
|
117
117
|
this.writer = t;
|
|
118
118
|
}
|
|
@@ -127,52 +127,52 @@ class Y {
|
|
|
127
127
|
return typeof t == "string" ? { body: t } : t.length > -1 && typeof t == "object" ? { items: t } : t;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
var E = /* @__PURE__ */ ((
|
|
131
|
-
const x = (
|
|
130
|
+
var E = /* @__PURE__ */ ((i) => (i.User = "user", i.Agent = "agent", i.System = "system", i))(E || {});
|
|
131
|
+
const x = (i) => {
|
|
132
132
|
let t, e = j(), s = Date.now();
|
|
133
|
-
if (
|
|
134
|
-
typeof
|
|
135
|
-
else if (typeof
|
|
136
|
-
t = { body:
|
|
137
|
-
else if (
|
|
138
|
-
t = p({},
|
|
133
|
+
if (i.length > -1 && typeof i == "object")
|
|
134
|
+
typeof i[0] == "string" ? t = { items: [i] } : t = { items: i };
|
|
135
|
+
else if (typeof i == "string")
|
|
136
|
+
t = { body: i };
|
|
137
|
+
else if (i = i, i.type)
|
|
138
|
+
t = p({}, i);
|
|
139
139
|
else {
|
|
140
140
|
if (t = {
|
|
141
|
-
body:
|
|
142
|
-
actions:
|
|
143
|
-
title:
|
|
144
|
-
},
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
t.form =
|
|
141
|
+
body: i.body,
|
|
142
|
+
actions: i.actions,
|
|
143
|
+
title: i.title
|
|
144
|
+
}, i.key && (e = i.key), i.timestamp && (s = i.timestamp), i.form) {
|
|
145
|
+
const r = J.create(e);
|
|
146
|
+
i.form(r);
|
|
147
|
+
const n = r.get();
|
|
148
|
+
t.form = n;
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
i.timestamp === null && (s = null);
|
|
151
151
|
}
|
|
152
152
|
return { content: t, key: e, timestamp: s };
|
|
153
|
-
}, O = (
|
|
153
|
+
}, O = (i, t) => {
|
|
154
154
|
if (!t)
|
|
155
155
|
return;
|
|
156
|
-
const e = JSON.stringify(t), s =
|
|
156
|
+
const e = JSON.stringify(t), s = i.findIndex((r) => e === JSON.stringify(r));
|
|
157
157
|
if (s > -1)
|
|
158
|
-
return
|
|
158
|
+
return i.splice(s, 1);
|
|
159
159
|
};
|
|
160
160
|
class X {
|
|
161
161
|
constructor(t, e) {
|
|
162
|
-
this.container = t, this.id = e, this.formHandlers = {}, this.user = new
|
|
163
|
-
const
|
|
164
|
-
return this.createEntry(
|
|
162
|
+
this.container = t, this.id = e, this.formHandlers = {}, this.user = new Y(this), this.providers = [], this.active = !1, this.registeredProviders = [], this.loaders = 0, this.componentMounted = !1, this.messages = [], this.typingActors = [], this.print = (r) => {
|
|
163
|
+
const n = x(r);
|
|
164
|
+
return this.createEntry(n.key, n.content, "system", void 0, n.timestamp);
|
|
165
165
|
};
|
|
166
166
|
const s = t.get("$widget");
|
|
167
167
|
this.events = s.events.createChild(this);
|
|
168
168
|
}
|
|
169
169
|
setProviders(t) {
|
|
170
170
|
const e = [], s = [];
|
|
171
|
-
this.providers.reduce((
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
}), t.forEach((
|
|
175
|
-
this.providers.indexOf(
|
|
171
|
+
this.providers.reduce((r, n) => (t.indexOf(n) === -1 && r.push(n), r), []).forEach((r) => {
|
|
172
|
+
const n = this.providers.indexOf(r);
|
|
173
|
+
n > -1 && (e.push(r), this.providers.splice(n, 1));
|
|
174
|
+
}), t.forEach((r) => {
|
|
175
|
+
this.providers.indexOf(r) === -1 && (s.push(r), this.providers.push(r));
|
|
176
176
|
}), (s.length || e.length) && this.events.dispatch("conversation:providers-changed", { added: s, removed: e });
|
|
177
177
|
}
|
|
178
178
|
createProvider(t) {
|
|
@@ -210,22 +210,22 @@ class X {
|
|
|
210
210
|
onUnreadMessage(t) {
|
|
211
211
|
return this.events.subscribe("conversation:unread-message", t);
|
|
212
212
|
}
|
|
213
|
-
createEntry(t, e, s,
|
|
213
|
+
createEntry(t, e, s, r, n) {
|
|
214
214
|
const o = {
|
|
215
215
|
key: t,
|
|
216
216
|
content: e,
|
|
217
217
|
type: s,
|
|
218
|
-
sender:
|
|
219
|
-
timestamp:
|
|
218
|
+
sender: r || null,
|
|
219
|
+
timestamp: n || n === null ? n : Date.now()
|
|
220
220
|
};
|
|
221
|
-
this.messages.push(o), o.type === "agent" && O(this.typingActors,
|
|
222
|
-
const a = new
|
|
221
|
+
this.messages.push(o), o.type === "agent" && O(this.typingActors, r);
|
|
222
|
+
const a = new q((c) => {
|
|
223
223
|
if (c !== null) {
|
|
224
|
-
const h = c, { timestamp:
|
|
225
|
-
o.content = f,
|
|
224
|
+
const h = c, { timestamp: d = void 0 } = h, f = R(h, ["timestamp"]);
|
|
225
|
+
o.content = f, d && (o.timestamp = d);
|
|
226
226
|
} else {
|
|
227
|
-
const
|
|
228
|
-
o.content = null,
|
|
227
|
+
const d = this.messages.indexOf(o);
|
|
228
|
+
o.content = null, d > -1 && this.messages.splice(d, 1);
|
|
229
229
|
}
|
|
230
230
|
this.events.dispatch("conversation:message-updated", { message: o }), this.update();
|
|
231
231
|
});
|
|
@@ -264,28 +264,28 @@ class X {
|
|
|
264
264
|
this.formHandlers[t] = g(p({}, this.formHandlers[t]), { validate: e });
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
-
const Z = (
|
|
268
|
-
const e =
|
|
267
|
+
const Z = (i, t) => {
|
|
268
|
+
const e = i.split("_contact");
|
|
269
269
|
return t.widgets.get(e[0]);
|
|
270
|
-
}, I = (
|
|
271
|
-
const t =
|
|
272
|
-
return c && !o ? { chatWidget: c, mainWidget:
|
|
273
|
-
}, tt = (
|
|
274
|
-
const { chatWidget: t } = I(
|
|
270
|
+
}, I = (i) => {
|
|
271
|
+
const t = i.get("$widget"), { name: e, implementation: s } = i.get("$widget"), r = e.indexOf("_contact") > -1 ? Z(e, s) : t, { data: n } = i.get("$settings"), { trigger: o } = r.container.get("$settings"), a = `${e.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(a);
|
|
272
|
+
return c && !o ? { chatWidget: c, mainWidget: r, data: n } : { mainWidget: r, data: n };
|
|
273
|
+
}, tt = (i) => {
|
|
274
|
+
const { chatWidget: t } = I(i);
|
|
275
275
|
return !!t;
|
|
276
|
-
}, B = (
|
|
277
|
-
const { mainWidget: s, data:
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
o.navigateToConversationIfActive(t.id).then(() =>
|
|
276
|
+
}, B = (i, t, e) => {
|
|
277
|
+
const { mainWidget: s, data: r, chatWidget: n } = I(i);
|
|
278
|
+
return n ? n.state === "activated" ? n.invoke("open").then(() => {
|
|
279
|
+
n.container.getAsync("conversation").then((o) => {
|
|
280
|
+
o.navigateToConversationIfActive(t.id).then(() => M(i));
|
|
281
281
|
});
|
|
282
|
-
}) :
|
|
283
|
-
const { trigger: o } =
|
|
284
|
-
return o.action = "hide",
|
|
285
|
-
data:
|
|
282
|
+
}) : n.activate().then(() => {
|
|
283
|
+
const { trigger: o } = n.container.get("$settings");
|
|
284
|
+
return o.action = "hide", n.invoke("setSettings", () => ({
|
|
285
|
+
data: r,
|
|
286
286
|
trigger: o,
|
|
287
287
|
activate: !0
|
|
288
|
-
})).then(() =>
|
|
288
|
+
})).then(() => n.container.getAsync("components").then((a) => {
|
|
289
289
|
const c = a.components().ofType("contact-method");
|
|
290
290
|
a.write({
|
|
291
291
|
key: "setContactMethodId",
|
|
@@ -308,23 +308,23 @@ const Z = (r, t) => {
|
|
|
308
308
|
provider: "localStorage"
|
|
309
309
|
});
|
|
310
310
|
}));
|
|
311
|
-
}).then(() =>
|
|
311
|
+
}).then(() => n.invoke("attach", {
|
|
312
312
|
key: "contact-method",
|
|
313
313
|
triggerDOMElement: e,
|
|
314
314
|
withRenderState: "open"
|
|
315
|
-
})).then(() => (
|
|
315
|
+
})).then(() => (z(n.container, "activeStickyWidget", $.Necessary, {
|
|
316
316
|
medium: m.Local,
|
|
317
|
-
scope:
|
|
318
|
-
}).then((o) => o(
|
|
319
|
-
o.setConversationEndedBehavior(
|
|
320
|
-
}).then(() =>
|
|
321
|
-
}, et = (
|
|
322
|
-
const { mainWidget: s, chatWidget:
|
|
323
|
-
return
|
|
324
|
-
|
|
325
|
-
}) : s.container.getAsync("conversation").then((
|
|
317
|
+
scope: L.Implementation
|
|
318
|
+
}).then((o) => o(n.name)), n.container.getAsync("conversation").then((o) => {
|
|
319
|
+
o.setConversationEndedBehavior(P.Deactivate);
|
|
320
|
+
}).then(() => M(i)).then(() => !1))) : (s.container.getAsync("conversation").then((o) => o.navigateToConversationIfActive(t.id).then(() => o.setConversationEndedBehavior(P.Navigate))), !n);
|
|
321
|
+
}, et = (i, t, e = "conversation") => {
|
|
322
|
+
const { mainWidget: s, chatWidget: r } = I(i);
|
|
323
|
+
return r ? r.container.getAsync("router").then((n) => {
|
|
324
|
+
n.navigate(e, { id: t.id });
|
|
325
|
+
}) : s.container.getAsync("conversation").then((n) => {
|
|
326
326
|
var o;
|
|
327
|
-
(o =
|
|
327
|
+
(o = n.setConversationEndedBehavior(P.Navigate)) == null || o.then(() => {
|
|
328
328
|
s.container.getAsync("router").then((a) => {
|
|
329
329
|
s.container.getAsync("components").then((c) => {
|
|
330
330
|
const h = c.components().ofType("conversation");
|
|
@@ -341,7 +341,7 @@ const Z = (r, t) => {
|
|
|
341
341
|
});
|
|
342
342
|
});
|
|
343
343
|
}, y = "conversations";
|
|
344
|
-
var
|
|
344
|
+
var P = /* @__PURE__ */ ((i) => (i.Deactivate = "deactivate", i.Navigate = "navigate", i.None = "none", i))(P || {});
|
|
345
345
|
class b {
|
|
346
346
|
constructor(t, e) {
|
|
347
347
|
this.container = t, this.components = e, this.controllers = [], this.providers = [], this.disposeProviders = {}, this.subscriptions = [], this.storageWriter = null, this.router = null, this.buttonQuery = null, this.sessionInfo = null;
|
|
@@ -349,19 +349,19 @@ class b {
|
|
|
349
349
|
this.events = s.events.createChild(this);
|
|
350
350
|
}
|
|
351
351
|
initialize() {
|
|
352
|
-
|
|
352
|
+
z(this.container, y, $.Necessary, {
|
|
353
353
|
medium: m.Local
|
|
354
354
|
}).then((t) => this.storageWriter = t), A(this.container, y, m.Local).then((t) => {
|
|
355
355
|
this.buttonQuery = this.components.components().ofType("conversation-return-button"), t && (this.sessionInfo = t, t.id && t.route && this.writeToComponents({ active: !0, alert: { show: !1 } }));
|
|
356
356
|
}), this.container.getAsync("router").then((t) => this.router = t), this.events.subscribe("conversation:ended", (t, e) => {
|
|
357
|
-
var s,
|
|
357
|
+
var s, r, n;
|
|
358
358
|
switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
|
|
359
359
|
case "deactivate":
|
|
360
360
|
this.container.get("$widget").deactivate();
|
|
361
361
|
break;
|
|
362
362
|
case "navigate":
|
|
363
|
-
const a = (
|
|
364
|
-
a && ((
|
|
363
|
+
const a = (r = this.router) == null ? void 0 : r.getInitialRoute();
|
|
364
|
+
a && ((n = this.router) == null || n.navigate(a.name));
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
this.writeToComponents({ active: !1 }), this.sessionInfo = null, this.storageWriter && this.storageWriter();
|
|
@@ -371,17 +371,17 @@ class b {
|
|
|
371
371
|
this.subscriptions.push(t);
|
|
372
372
|
}
|
|
373
373
|
static getInstance(t, e = "conversation") {
|
|
374
|
-
return
|
|
375
|
-
let
|
|
376
|
-
return
|
|
374
|
+
return G(t)(() => t.getAsync(e).then((s) => {
|
|
375
|
+
let r = s;
|
|
376
|
+
return r || H.getInstance(t).then((n) => (r = new b(t, n), r.initialize(), t.registerAsync(e, () => r), r));
|
|
377
377
|
}));
|
|
378
378
|
}
|
|
379
379
|
navigateToConversationIfActive(t) {
|
|
380
380
|
return A(this.container, y, m.Local).then((e) => {
|
|
381
381
|
var s;
|
|
382
382
|
if (e && e.id === t && e.route) {
|
|
383
|
-
const { name:
|
|
384
|
-
(s = this.router) == null || s.navigate(
|
|
383
|
+
const { name: r, params: n } = e.route;
|
|
384
|
+
(s = this.router) == null || s.navigate(r, n);
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
387
|
}
|
|
@@ -400,18 +400,18 @@ class b {
|
|
|
400
400
|
name: t,
|
|
401
401
|
handler: e
|
|
402
402
|
};
|
|
403
|
-
this.providers.push(s), this.controllers.filter((
|
|
404
|
-
this.invokeHandler(s,
|
|
403
|
+
this.providers.push(s), this.controllers.filter((r) => r.conversation.providers.indexOf(t) > -1).forEach((r) => {
|
|
404
|
+
this.invokeHandler(s, r);
|
|
405
405
|
});
|
|
406
406
|
}
|
|
407
407
|
registerController(t, e) {
|
|
408
|
-
const s = this.controllers.findIndex((
|
|
409
|
-
let
|
|
408
|
+
const s = this.controllers.findIndex((n) => n.conversation.id === t.id);
|
|
409
|
+
let r;
|
|
410
410
|
if (s < 0) {
|
|
411
|
-
|
|
412
|
-
const
|
|
411
|
+
r = { conversation: t, component: e }, this.controllers.push(r);
|
|
412
|
+
const n = (o) => {
|
|
413
413
|
o && this.providers.filter((a) => o.indexOf(a.name) > -1).forEach((a) => {
|
|
414
|
-
this.invokeHandler(a,
|
|
414
|
+
this.invokeHandler(a, r);
|
|
415
415
|
});
|
|
416
416
|
};
|
|
417
417
|
return this.subscriptions.push(t.onDispose((o, a) => {
|
|
@@ -419,24 +419,24 @@ class b {
|
|
|
419
419
|
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 });
|
|
420
420
|
})), this.subscriptions.push(t.onProvidersChange((o, a) => {
|
|
421
421
|
const { added: c, removed: h } = a;
|
|
422
|
-
h.forEach((
|
|
423
|
-
this.disposeProviders[
|
|
422
|
+
h.forEach((d) => {
|
|
423
|
+
this.disposeProviders[d].forEach((f) => {
|
|
424
424
|
f();
|
|
425
425
|
});
|
|
426
|
-
}),
|
|
426
|
+
}), n(c);
|
|
427
427
|
})), this.subscriptions.push(t.onStarted((o, a) => {
|
|
428
|
-
var h,
|
|
428
|
+
var h, d;
|
|
429
429
|
const c = {
|
|
430
430
|
id: t.id,
|
|
431
431
|
route: (h = this.router) == null ? void 0 : h.getRouteData(),
|
|
432
|
-
conversationEndedBehavior: (
|
|
432
|
+
conversationEndedBehavior: (d = this.sessionInfo) == null ? void 0 : d.conversationEndedBehavior
|
|
433
433
|
};
|
|
434
434
|
this.sessionInfo = c, this.storageWriter && this.storageWriter(c), this.writeToComponents({ active: a });
|
|
435
435
|
})), this.subscriptions.push(t.onUnreadMessage((o, a) => {
|
|
436
436
|
this.events.dispatch("conversation:unread-message", a), this.writeToComponents({ alert: { show: a } });
|
|
437
|
-
})),
|
|
437
|
+
})), n(t.providers), !0;
|
|
438
438
|
}
|
|
439
|
-
return
|
|
439
|
+
return r = this.controllers[s], !1;
|
|
440
440
|
}
|
|
441
441
|
writeToComponents(t, e = "conversationReturnButtonState") {
|
|
442
442
|
this.buttonQuery && this.components.write({
|
|
@@ -462,25 +462,26 @@ class b {
|
|
|
462
462
|
t();
|
|
463
463
|
}), this.controllers = [], this.providers = [];
|
|
464
464
|
}
|
|
465
|
-
static handleContactMethodClick(t, e, s,
|
|
466
|
-
return
|
|
465
|
+
static handleContactMethodClick(t, e, s, r) {
|
|
466
|
+
return S(this, null, function* () {
|
|
467
467
|
if (tt(e)) {
|
|
468
468
|
t.preventDefault();
|
|
469
|
-
let
|
|
470
|
-
|
|
469
|
+
let n = document.getElementById("humany-dynamic-anchor");
|
|
470
|
+
n || (n = document.createElement("a"), n.setAttribute("href", "#"), n.id = "humany-dynamic-anchor", document.body.appendChild(n)), B(e, s, n);
|
|
471
471
|
}
|
|
472
472
|
B(e, s);
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
static handleContactMethodSubmit(t, e) {
|
|
476
|
-
return
|
|
476
|
+
return S(this, null, function* () {
|
|
477
477
|
return et(t, e);
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
|
|
481
|
+
var st = /* @__PURE__ */ ((i) => (i.Header = "header", i.LinkList = "link-list", i.Separator = "separator", i.NoGoodAlternative = "no-good-alternative", i.ButtonList = "button-list", i.Text = "text", i.HTML = "html", i.FeedbackList = "feedback-list", i))(st || {});
|
|
482
|
+
const it = (i, t) => i.reduce((e, s, r) => {
|
|
482
483
|
var o, a;
|
|
483
|
-
const
|
|
484
|
+
const n = g(p({}, s), {
|
|
484
485
|
content: [g(p({}, s.content), { key: s.key })]
|
|
485
486
|
});
|
|
486
487
|
if (e.length > 0 && s.type !== E.System) {
|
|
@@ -488,30 +489,30 @@ const st = (r, t) => r.reduce((e, s, n) => {
|
|
|
488
489
|
if ((!t && t !== 0 || Math.abs(c.timestamp - s.timestamp) < t) && ((o = c.sender) == null ? void 0 : o.name) === ((a = s.sender) == null ? void 0 : a.name) && c.type === s.type)
|
|
489
490
|
return c.timestamp = s.timestamp, c.content.push(g(p({}, s.content), { key: s.key })), e;
|
|
490
491
|
}
|
|
491
|
-
return e.push(
|
|
492
|
-
}, []), lt = (
|
|
493
|
-
b.getInstance(
|
|
494
|
-
|
|
495
|
-
]).then(([t, e]) => Q(
|
|
496
|
-
const
|
|
497
|
-
const { providers:
|
|
498
|
-
if (
|
|
499
|
-
const v = Array.isArray(
|
|
492
|
+
return e.push(n), e;
|
|
493
|
+
}, []), lt = (i) => Promise.all([
|
|
494
|
+
b.getInstance(i),
|
|
495
|
+
i.getAsync("router")
|
|
496
|
+
]).then(([t, e]) => Q(i, "conversation", import("./conversation.3981560b.js"), (s) => {
|
|
497
|
+
const n = e.getRouteData().params.id || s.node.name || "component", o = t.createController(n), a = t.registerController(o, s), c = 3 * 60 * 1e3, h = (l) => {
|
|
498
|
+
const { providers: u = [] } = l;
|
|
499
|
+
if (u) {
|
|
500
|
+
const v = Array.isArray(u) ? u : [u];
|
|
500
501
|
return o.setProviders(v), v;
|
|
501
502
|
}
|
|
502
503
|
};
|
|
503
504
|
h(s.properties(h)), o.setComponentMountedState(!0);
|
|
504
|
-
const
|
|
505
|
-
const { loading:
|
|
505
|
+
const d = (l) => {
|
|
506
|
+
const { loading: u, typingActors: v, messages: w } = l;
|
|
506
507
|
s.writeProperties({
|
|
507
|
-
loading:
|
|
508
|
+
loading: u,
|
|
508
509
|
typingActors: v,
|
|
509
|
-
messages:
|
|
510
|
+
messages: it(w, c)
|
|
510
511
|
});
|
|
511
512
|
};
|
|
512
|
-
|
|
513
|
-
if (
|
|
514
|
-
const { preventDefault: v, validationPromise: w } =
|
|
513
|
+
d(o.getMessageStream()), a && (s.actions.create("user-submit", (l, u) => {
|
|
514
|
+
if (u) {
|
|
515
|
+
const { preventDefault: v, validationPromise: w } = u;
|
|
515
516
|
if (v) {
|
|
516
517
|
w && w().then((W) => {
|
|
517
518
|
W && o.user.print(W);
|
|
@@ -520,55 +521,36 @@ const st = (r, t) => r.reduce((e, s, n) => {
|
|
|
520
521
|
}
|
|
521
522
|
}
|
|
522
523
|
o.user.print(l.text);
|
|
523
|
-
}), s.actions.create("user-typing", (l,
|
|
524
|
-
}), s.actions.create("form", (l,
|
|
525
|
-
}), s.actions.create("action", (l,
|
|
526
|
-
}), s.actions.create("overlay-mounted", (l, d) => {
|
|
527
|
-
}), s.actions.create("show-overlay", (l, d) => {
|
|
528
|
-
s.writeProperties({
|
|
529
|
-
overlay: { conversation: !1, secondary: !1 }
|
|
530
|
-
});
|
|
531
|
-
}), s.actions.create("hide-overlay", (l, d) => {
|
|
532
|
-
s.writeProperties({
|
|
533
|
-
overlay: null
|
|
534
|
-
});
|
|
535
|
-
}), s.actions.create("show-overlay-conversation", (l, d) => {
|
|
536
|
-
s.writeProperties({
|
|
537
|
-
overlay: { conversation: !0, secondary: !1 }
|
|
538
|
-
});
|
|
539
|
-
}), s.actions.create("hide-overlay-conversation", (l, d) => {
|
|
540
|
-
s.writeProperties({
|
|
541
|
-
overlay: { conversation: !1, secondary: !1 }
|
|
542
|
-
});
|
|
524
|
+
}), s.actions.create("user-typing", (l, u) => {
|
|
525
|
+
}), s.actions.create("form", (l, u) => {
|
|
526
|
+
}), s.actions.create("action", (l, u) => {
|
|
543
527
|
}));
|
|
544
|
-
const f = o.events.subscribe("conversation:updated", (l,
|
|
545
|
-
u
|
|
528
|
+
const f = o.events.subscribe("conversation:updated", (l, u) => {
|
|
529
|
+
d(u);
|
|
546
530
|
});
|
|
547
531
|
return () => {
|
|
548
|
-
o.setComponentMountedState(!1), f(), o.active ||
|
|
532
|
+
o.setComponentMountedState(!1), f(), o.active || d({ messages: [], typingActors: [], loading: !1 });
|
|
549
533
|
};
|
|
550
|
-
}, { reuseController: !0 })), pt = (
|
|
551
|
-
|
|
552
|
-
b.getInstance(
|
|
553
|
-
|
|
554
|
-
]).then(([t, e, s]) => Q(
|
|
555
|
-
|
|
534
|
+
}, { reuseController: !0 })), pt = (i) => Promise.all([
|
|
535
|
+
H.getInstance(i),
|
|
536
|
+
b.getInstance(i),
|
|
537
|
+
i.getAsync("router")
|
|
538
|
+
]).then(([t, e, s]) => Q(i, "conversation-return-button", import("./return-button.8773c0de.js"), (r) => {
|
|
539
|
+
r.actions.create("toggle", (n = {}) => {
|
|
556
540
|
var o;
|
|
557
541
|
(o = e.getComponentRoute()) == null || o.then((a) => {
|
|
558
542
|
a && s.navigate(a.name, a.params);
|
|
559
543
|
});
|
|
560
544
|
});
|
|
561
|
-
}))
|
|
562
|
-
|
|
563
|
-
const vt = (r, t, e) => r.getAsync("componentResolver").then((s) => P(void 0, null, function* () {
|
|
564
|
-
(yield b.getInstance(r)).addSubscription(s.registerComponent(t, J(() => e)));
|
|
545
|
+
})), vt = (i, t, e) => i.getAsync("componentResolver").then((s) => S(void 0, null, function* () {
|
|
546
|
+
(yield b.getInstance(i)).addSubscription(s.registerComponent(t, K(() => e)));
|
|
565
547
|
}));
|
|
566
548
|
export {
|
|
567
549
|
lt as ConversationComponent,
|
|
568
550
|
X as ConversationController,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
551
|
+
P as ConversationEndedBehavior,
|
|
552
|
+
q as ConversationEntry,
|
|
553
|
+
st as ConversationMessageListItemType,
|
|
572
554
|
E as ConversationMessageType,
|
|
573
555
|
b as ConversationPlatform,
|
|
574
556
|
pt as ConversationReturnButtonComponent,
|