@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/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 = (i, e, t) => e in i ? F(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, m = (i, e) => {
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(i, t, e[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(i, t, e[t]);
11
- return i;
12
- }, b = (i, e) => G(i, J(e));
13
- var B = (i, e) => {
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 i)
16
- $.call(i, s) && e.indexOf(s) < 0 && (t[s] = i[s]);
17
- if (i != null && x)
18
- for (var s of x(i))
19
- e.indexOf(s) < 0 && _.call(i, s) && (t[s] = i[s]);
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 = (i, e, t) => (T(i, typeof e != "symbol" ? e + "" : e, t), t);
23
- var v = (i, e, t) => new Promise((s, r) => {
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
- r(h);
28
+ i(h);
29
29
  }
30
30
  }, a = (c) => {
31
31
  try {
32
32
  o(t.throw(c));
33
33
  } catch (h) {
34
- r(h);
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(i, e)).next());
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 D, StorageCategory as N, readStorage as w, StorageMedium as A, StorageScope as V } from "@telia-ace/widget-services";
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", (r, n) => {
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 r = I(s), { key: n, content: a, type: o, sender: c, timestamp: h } = r.content, u = this.parseEntry(a, o, c, h);
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, r) {
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: r
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: r, label: n, description: a, text: o, html: c, body: h, contactMethodId: u } = e;
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)), r && (l = this.appendText(l, r, 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;
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(([r, n]) => ({
126
- actionKey: r,
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((r) => this.getDetails(r, !1))), t;
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 M {
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
- }, r = I(e, t);
150
+ }, i = I(e, t);
151
151
  return this.provider.createEntry(
152
- r.key,
153
- r.content,
152
+ i.key,
153
+ i.content,
154
154
  S.Agent,
155
155
  s,
156
- r.timestamp
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 r;
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), (r = this.provider.controller) == null || r.events.dispatch("conversation:agent-updated", {
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), r = s ? new M(this, m(m({}, s), e)) : new M(this, e);
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: r
188
- }), r;
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, r, n) {
203
+ createEntry(e, t, s, i, n) {
204
204
  var a;
205
- return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, r, n);
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 = (i) => `conversation-${i}`;
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
- (r) => e = () => {
261
- this._locks -= 1, r();
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: r } = yield this.read(), n = [];
276
- r && r.forEach((o) => {
277
- const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new M(h, { name: o.name, avatar: o.avatar, id: o.id });
275
+ 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((r, n) => v(this, null, function* () {
304
+ })), t.onMessageCreated((i, n) => v(this, null, function* () {
305
305
  this.write(n.message, "messages");
306
- })), t.events.subscribe("conversation:agent-created", (r, n) => v(this, null, function* () {
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", (r, n) => v(this, null, function* () {
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 r = yield this.locker.lock();
346
- return D(
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
- r();
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
- r();
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
- r();
367
+ i();
368
368
  });
369
369
  }
370
370
  return n(e).then(() => {
371
- r();
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 W = (i, e, t) => v(void 0, null, function* () {
402
- const s = yield i.getAsync("conversation"), r = yield i.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
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 = r.components().ofType("conversation");
409
- r.write({
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__ */ ((i) => (i.User = "user", i.Agent = "agent", i.System = "system", i))(S || {});
435
- const I = (i, e) => {
436
- let t, s = (e == null ? void 0 : e.key) || U(), r = Date.now();
437
- if (Array.isArray(i) && i.length > -1)
438
- typeof i[0] == "string" ? t = { items: [i] } : t = { items: i };
439
- else if (typeof i == "string")
440
- t = { body: i };
441
- else if (i = i || {}, i.type)
442
- t = m({}, i);
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: i.body,
446
- actions: i.actions,
447
- title: i.title
448
- }, i.key && (s = i.key), i.timestamp && (r = i.timestamp), typeof i.form == "function") {
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
- i.form(n);
450
+ r.form(n);
451
451
  const a = n.get();
452
452
  t.form = a;
453
453
  }
454
- i.timestamp === null && (r = null);
454
+ r.timestamp === null && (i = null);
455
455
  }
456
- return { content: t, key: s, timestamp: r };
457
- }, z = (i, e) => {
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 = i.findIndex((r) => t === JSON.stringify(r));
460
+ const t = JSON.stringify(e), s = r.findIndex((i) => t === JSON.stringify(i));
461
461
  if (s > -1)
462
- return i.splice(s, 1);
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 r = e.get("$widget");
491
- this.events = r.events.createChild(this), this.store = new re(e, this, s.rehydrate), this.conversationHistory = new ee(this);
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((r, n) => (e.indexOf(n) === -1 && r.push(n), r), []).forEach((r) => {
499
- const n = this.providers.indexOf(r);
500
- n > -1 && (t.push(r), this.providers.splice(n, 1));
501
- }), e.forEach((r) => {
502
- this.providers.indexOf(r) === -1 && (s.push(r), this.providers.push(r));
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) && W(this.container, this.id, 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 && W(this.container, this.id, 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, r, n) {
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: r || null,
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, r);
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 = (i, e) => {
622
- const t = i.split("_contact");
621
+ const ae = (r, e) => {
622
+ const t = r.split("_contact");
623
623
  return e.widgets.get(t[0]);
624
- }, R = (i) => {
625
- const e = i.get("$widget"), { name: t, implementation: s } = i.get("$widget"), r = t.indexOf("_contact") > -1 ? ae(t, s) : e, { data: n } = i.get("$settings"), { trigger: a } = r.container.get("$settings"), o = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(o);
626
- return c && !a ? { chatWidget: c, mainWidget: r, data: n } : { mainWidget: r, data: n };
627
- }, ce = (i) => {
628
- const { chatWidget: e } = R(i);
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 = (i, e, t) => {
631
- const { mainWidget: s, data: r, chatWidget: n } = R(i);
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(i));
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: r,
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(() => (D(
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(i)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(E.Navigate))), !n);
680
- }, de = (i, e, t = "conversation") => {
681
- const { mainWidget: s, chatWidget: r } = R(i);
682
- return r ? r.container.getAsync("router").then((n) => {
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__ */ ((i) => (i.Deactivate = "deactivate", i.Navigate = "navigate", i.None = "none", i))(E || {});
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
- D(this.container, P, N.Necessary, {
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, r, n;
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 = (r = this.router) == null ? void 0 : r.getInitialRoute();
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 r = s;
746
- return r || Q.getInstance(e).then((n) => (r = new C(e, n), r.initialize(), e.registerAsync(t, () => r), r));
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: r, params: n } = t.route;
755
- (s = this.router) == null || s.navigate(r, n);
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: r } = (yield w(
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: r || [] }), a;
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((r) => r.conversation.providers.indexOf(e) > -1).forEach((r) => {
784
- this.invokeHandler(s, r);
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 r;
789
+ let i;
790
790
  if (s < 0) {
791
- r = { conversation: e, component: t }, this.controllers.push(r);
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, r);
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 r = this.controllers[s], !1;
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, r) {
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, r;
871
- return (r = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && r.id ? W(
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 = (i, e) => i.reduce((t, s, r) => {
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 = (i) => Promise.all([
891
- C.getInstance(i),
892
- i.getAsync("router")
890
+ }, []), we = (r) => Promise.all([
891
+ C.getInstance(r),
892
+ r.getAsync("router")
893
893
  ]).then(([e, t]) => q(
894
- i,
894
+ r,
895
895
  "conversation",
896
- import("./conversation.f80bcb4a.js"),
896
+ import("./conversation.be64b43a.js"),
897
897
  (s) => v(void 0, null, function* () {
898
- const { rehydrate: r = !1 } = s.properties(), a = t.getRouteData().params.id || s.node.name || "component", o = yield e.createController(a, { rehydrate: r }), c = e.registerController(o, s), h = 3 * 60 * 1e3, u = (g) => {
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 = (i) => Promise.all([
958
- Q.getInstance(i),
959
- C.getInstance(i),
960
- i.getAsync("router")
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
- i,
963
+ r,
964
964
  "conversation-return-button",
965
965
  import("./return-button.fb63a16e.js"),
966
- (r) => {
967
- r.actions.create("toggle", (n = {}) => {
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__ */ ((i) => (i.LinkList = "link-list", i.Separator = "separator", i.ButtonList = "button-list", i.Text = "text", i.HTML = "html", i.VideoRequest = "video-request", i))(le || {});
977
- const Pe = (i, e, t) => i.getAsync("componentResolver").then((s) => v(void 0, null, function* () {
978
- (yield C.getInstance(i)).addSubscription(
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)