@telia-ace/widget-conversation-flamingo 1.1.14-rc.2 → 1.1.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,773 @@
1
+ let m;
2
+ const G = new Uint8Array(16);
3
+ function J() {
4
+ if (!m && (m = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !m))
5
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
6
+ return m(G);
7
+ }
8
+ const a = [];
9
+ for (let e = 0; e < 256; ++e)
10
+ a.push((e + 256).toString(16).slice(1));
11
+ function Q(e, r = 0) {
12
+ return a[e[r + 0]] + a[e[r + 1]] + a[e[r + 2]] + a[e[r + 3]] + "-" + a[e[r + 4]] + a[e[r + 5]] + "-" + a[e[r + 6]] + a[e[r + 7]] + "-" + a[e[r + 8]] + a[e[r + 9]] + "-" + a[e[r + 10]] + a[e[r + 11]] + a[e[r + 12]] + a[e[r + 13]] + a[e[r + 14]] + a[e[r + 15]];
13
+ }
14
+ const W = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), B = {
15
+ randomUUID: W
16
+ };
17
+ function X(e, r, t) {
18
+ if (B.randomUUID && !r && !e)
19
+ return B.randomUUID();
20
+ e = e || {};
21
+ const n = e.random || (e.rng || J)();
22
+ if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, r) {
23
+ t = t || 0;
24
+ for (let i = 0; i < 16; ++i)
25
+ r[t + i] = n[i];
26
+ return r;
27
+ }
28
+ return Q(n);
29
+ }
30
+ var P = function(e, r) {
31
+ return P = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
32
+ t.__proto__ = n;
33
+ } || function(t, n) {
34
+ for (var i in n)
35
+ Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]);
36
+ }, P(e, r);
37
+ };
38
+ function d(e, r) {
39
+ if (typeof r != "function" && r !== null)
40
+ throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
41
+ P(e, r);
42
+ function t() {
43
+ this.constructor = e;
44
+ }
45
+ e.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
46
+ }
47
+ function A(e) {
48
+ var r = typeof Symbol == "function" && Symbol.iterator, t = r && e[r], n = 0;
49
+ if (t)
50
+ return t.call(e);
51
+ if (e && typeof e.length == "number")
52
+ return {
53
+ next: function() {
54
+ return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
55
+ }
56
+ };
57
+ throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
58
+ }
59
+ function w(e, r) {
60
+ var t = typeof Symbol == "function" && e[Symbol.iterator];
61
+ if (!t)
62
+ return e;
63
+ var n = t.call(e), i, o = [], s;
64
+ try {
65
+ for (; (r === void 0 || r-- > 0) && !(i = n.next()).done; )
66
+ o.push(i.value);
67
+ } catch (u) {
68
+ s = { error: u };
69
+ } finally {
70
+ try {
71
+ i && !i.done && (t = n.return) && t.call(n);
72
+ } finally {
73
+ if (s)
74
+ throw s.error;
75
+ }
76
+ }
77
+ return o;
78
+ }
79
+ function _(e, r, t) {
80
+ if (t || arguments.length === 2)
81
+ for (var n = 0, i = r.length, o; n < i; n++)
82
+ (o || !(n in r)) && (o || (o = Array.prototype.slice.call(r, 0, n)), o[n] = r[n]);
83
+ return e.concat(o || Array.prototype.slice.call(r));
84
+ }
85
+ function p(e) {
86
+ return typeof e == "function";
87
+ }
88
+ function H(e) {
89
+ var r = function(n) {
90
+ Error.call(n), n.stack = new Error().stack;
91
+ }, t = e(r);
92
+ return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
93
+ }
94
+ var U = H(function(e) {
95
+ return function(t) {
96
+ e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
97
+ ` + t.map(function(n, i) {
98
+ return i + 1 + ") " + n.toString();
99
+ }).join(`
100
+ `) : "", this.name = "UnsubscriptionError", this.errors = t;
101
+ };
102
+ });
103
+ function j(e, r) {
104
+ if (e) {
105
+ var t = e.indexOf(r);
106
+ 0 <= t && e.splice(t, 1);
107
+ }
108
+ }
109
+ var E = function() {
110
+ function e(r) {
111
+ this.initialTeardown = r, this.closed = !1, this._parentage = null, this._finalizers = null;
112
+ }
113
+ return e.prototype.unsubscribe = function() {
114
+ var r, t, n, i, o;
115
+ if (!this.closed) {
116
+ this.closed = !0;
117
+ var s = this._parentage;
118
+ if (s)
119
+ if (this._parentage = null, Array.isArray(s))
120
+ try {
121
+ for (var u = A(s), c = u.next(); !c.done; c = u.next()) {
122
+ var h = c.value;
123
+ h.remove(this);
124
+ }
125
+ } catch (l) {
126
+ r = { error: l };
127
+ } finally {
128
+ try {
129
+ c && !c.done && (t = u.return) && t.call(u);
130
+ } finally {
131
+ if (r)
132
+ throw r.error;
133
+ }
134
+ }
135
+ else
136
+ s.remove(this);
137
+ var f = this.initialTeardown;
138
+ if (p(f))
139
+ try {
140
+ f();
141
+ } catch (l) {
142
+ o = l instanceof U ? l.errors : [l];
143
+ }
144
+ var R = this._finalizers;
145
+ if (R) {
146
+ this._finalizers = null;
147
+ try {
148
+ for (var y = A(R), b = y.next(); !b.done; b = y.next()) {
149
+ var q = b.value;
150
+ try {
151
+ V(q);
152
+ } catch (l) {
153
+ o = o ?? [], l instanceof U ? o = _(_([], w(o)), w(l.errors)) : o.push(l);
154
+ }
155
+ }
156
+ } catch (l) {
157
+ n = { error: l };
158
+ } finally {
159
+ try {
160
+ b && !b.done && (i = y.return) && i.call(y);
161
+ } finally {
162
+ if (n)
163
+ throw n.error;
164
+ }
165
+ }
166
+ }
167
+ if (o)
168
+ throw new U(o);
169
+ }
170
+ }, e.prototype.add = function(r) {
171
+ var t;
172
+ if (r && r !== this)
173
+ if (this.closed)
174
+ V(r);
175
+ else {
176
+ if (r instanceof e) {
177
+ if (r.closed || r._hasParent(this))
178
+ return;
179
+ r._addParent(this);
180
+ }
181
+ (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(r);
182
+ }
183
+ }, e.prototype._hasParent = function(r) {
184
+ var t = this._parentage;
185
+ return t === r || Array.isArray(t) && t.includes(r);
186
+ }, e.prototype._addParent = function(r) {
187
+ var t = this._parentage;
188
+ this._parentage = Array.isArray(t) ? (t.push(r), t) : t ? [t, r] : r;
189
+ }, e.prototype._removeParent = function(r) {
190
+ var t = this._parentage;
191
+ t === r ? this._parentage = null : Array.isArray(t) && j(t, r);
192
+ }, e.prototype.remove = function(r) {
193
+ var t = this._finalizers;
194
+ t && j(t, r), r instanceof e && r._removeParent(this);
195
+ }, e.EMPTY = function() {
196
+ var r = new e();
197
+ return r.closed = !0, r;
198
+ }(), e;
199
+ }(), L = E.EMPTY;
200
+ function z(e) {
201
+ return e instanceof E || e && "closed" in e && p(e.remove) && p(e.add) && p(e.unsubscribe);
202
+ }
203
+ function V(e) {
204
+ p(e) ? e() : e.unsubscribe();
205
+ }
206
+ var K = {
207
+ onUnhandledError: null,
208
+ onStoppedNotification: null,
209
+ Promise: void 0,
210
+ useDeprecatedSynchronousErrorHandling: !1,
211
+ useDeprecatedNextContext: !1
212
+ }, I = {
213
+ setTimeout: function(e, r) {
214
+ for (var t = [], n = 2; n < arguments.length; n++)
215
+ t[n - 2] = arguments[n];
216
+ var i = I.delegate;
217
+ return i != null && i.setTimeout ? i.setTimeout.apply(i, _([e, r], w(t))) : setTimeout.apply(void 0, _([e, r], w(t)));
218
+ },
219
+ clearTimeout: function(e) {
220
+ var r = I.delegate;
221
+ return ((r == null ? void 0 : r.clearTimeout) || clearTimeout)(e);
222
+ },
223
+ delegate: void 0
224
+ };
225
+ function Z(e) {
226
+ I.setTimeout(function() {
227
+ throw e;
228
+ });
229
+ }
230
+ function k() {
231
+ }
232
+ function g(e) {
233
+ e();
234
+ }
235
+ var $ = function(e) {
236
+ d(r, e);
237
+ function r(t) {
238
+ var n = e.call(this) || this;
239
+ return n.isStopped = !1, t ? (n.destination = t, z(t) && t.add(n)) : n.destination = et, n;
240
+ }
241
+ return r.create = function(t, n, i) {
242
+ return new T(t, n, i);
243
+ }, r.prototype.next = function(t) {
244
+ this.isStopped || this._next(t);
245
+ }, r.prototype.error = function(t) {
246
+ this.isStopped || (this.isStopped = !0, this._error(t));
247
+ }, r.prototype.complete = function() {
248
+ this.isStopped || (this.isStopped = !0, this._complete());
249
+ }, r.prototype.unsubscribe = function() {
250
+ this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
251
+ }, r.prototype._next = function(t) {
252
+ this.destination.next(t);
253
+ }, r.prototype._error = function(t) {
254
+ try {
255
+ this.destination.error(t);
256
+ } finally {
257
+ this.unsubscribe();
258
+ }
259
+ }, r.prototype._complete = function() {
260
+ try {
261
+ this.destination.complete();
262
+ } finally {
263
+ this.unsubscribe();
264
+ }
265
+ }, r;
266
+ }(E), N = Function.prototype.bind;
267
+ function O(e, r) {
268
+ return N.call(e, r);
269
+ }
270
+ var tt = function() {
271
+ function e(r) {
272
+ this.partialObserver = r;
273
+ }
274
+ return e.prototype.next = function(r) {
275
+ var t = this.partialObserver;
276
+ if (t.next)
277
+ try {
278
+ t.next(r);
279
+ } catch (n) {
280
+ S(n);
281
+ }
282
+ }, e.prototype.error = function(r) {
283
+ var t = this.partialObserver;
284
+ if (t.error)
285
+ try {
286
+ t.error(r);
287
+ } catch (n) {
288
+ S(n);
289
+ }
290
+ else
291
+ S(r);
292
+ }, e.prototype.complete = function() {
293
+ var r = this.partialObserver;
294
+ if (r.complete)
295
+ try {
296
+ r.complete();
297
+ } catch (t) {
298
+ S(t);
299
+ }
300
+ }, e;
301
+ }(), T = function(e) {
302
+ d(r, e);
303
+ function r(t, n, i) {
304
+ var o = e.call(this) || this, s;
305
+ if (p(t) || !t)
306
+ s = {
307
+ next: t ?? void 0,
308
+ error: n ?? void 0,
309
+ complete: i ?? void 0
310
+ };
311
+ else {
312
+ var u;
313
+ o && K.useDeprecatedNextContext ? (u = Object.create(t), u.unsubscribe = function() {
314
+ return o.unsubscribe();
315
+ }, s = {
316
+ next: t.next && O(t.next, u),
317
+ error: t.error && O(t.error, u),
318
+ complete: t.complete && O(t.complete, u)
319
+ }) : s = t;
320
+ }
321
+ return o.destination = new tt(s), o;
322
+ }
323
+ return r;
324
+ }($);
325
+ function S(e) {
326
+ Z(e);
327
+ }
328
+ function rt(e) {
329
+ throw e;
330
+ }
331
+ var et = {
332
+ closed: !0,
333
+ next: k,
334
+ error: rt,
335
+ complete: k
336
+ }, nt = function() {
337
+ return typeof Symbol == "function" && Symbol.observable || "@@observable";
338
+ }();
339
+ function it(e) {
340
+ return e;
341
+ }
342
+ function ot(e) {
343
+ return e.length === 0 ? it : e.length === 1 ? e[0] : function(t) {
344
+ return e.reduce(function(n, i) {
345
+ return i(n);
346
+ }, t);
347
+ };
348
+ }
349
+ var C = function() {
350
+ function e(r) {
351
+ r && (this._subscribe = r);
352
+ }
353
+ return e.prototype.lift = function(r) {
354
+ var t = new e();
355
+ return t.source = this, t.operator = r, t;
356
+ }, e.prototype.subscribe = function(r, t, n) {
357
+ var i = this, o = ut(r) ? r : new T(r, t, n);
358
+ return g(function() {
359
+ var s = i, u = s.operator, c = s.source;
360
+ o.add(u ? u.call(o, c) : c ? i._subscribe(o) : i._trySubscribe(o));
361
+ }), o;
362
+ }, e.prototype._trySubscribe = function(r) {
363
+ try {
364
+ return this._subscribe(r);
365
+ } catch (t) {
366
+ r.error(t);
367
+ }
368
+ }, e.prototype.forEach = function(r, t) {
369
+ var n = this;
370
+ return t = Y(t), new t(function(i, o) {
371
+ var s = new T({
372
+ next: function(u) {
373
+ try {
374
+ r(u);
375
+ } catch (c) {
376
+ o(c), s.unsubscribe();
377
+ }
378
+ },
379
+ error: o,
380
+ complete: i
381
+ });
382
+ n.subscribe(s);
383
+ });
384
+ }, e.prototype._subscribe = function(r) {
385
+ var t;
386
+ return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(r);
387
+ }, e.prototype[nt] = function() {
388
+ return this;
389
+ }, e.prototype.pipe = function() {
390
+ for (var r = [], t = 0; t < arguments.length; t++)
391
+ r[t] = arguments[t];
392
+ return ot(r)(this);
393
+ }, e.prototype.toPromise = function(r) {
394
+ var t = this;
395
+ return r = Y(r), new r(function(n, i) {
396
+ var o;
397
+ t.subscribe(function(s) {
398
+ return o = s;
399
+ }, function(s) {
400
+ return i(s);
401
+ }, function() {
402
+ return n(o);
403
+ });
404
+ });
405
+ }, e.create = function(r) {
406
+ return new e(r);
407
+ }, e;
408
+ }();
409
+ function Y(e) {
410
+ var r;
411
+ return (r = e ?? K.Promise) !== null && r !== void 0 ? r : Promise;
412
+ }
413
+ function st(e) {
414
+ return e && p(e.next) && p(e.error) && p(e.complete);
415
+ }
416
+ function ut(e) {
417
+ return e && e instanceof $ || st(e) && z(e);
418
+ }
419
+ function ct(e) {
420
+ return p(e == null ? void 0 : e.lift);
421
+ }
422
+ function at(e) {
423
+ return function(r) {
424
+ if (ct(r))
425
+ return r.lift(function(t) {
426
+ try {
427
+ return e(t, this);
428
+ } catch (n) {
429
+ this.error(n);
430
+ }
431
+ });
432
+ throw new TypeError("Unable to lift unknown Observable type");
433
+ };
434
+ }
435
+ function lt(e, r, t, n, i) {
436
+ return new pt(e, r, t, n, i);
437
+ }
438
+ var pt = function(e) {
439
+ d(r, e);
440
+ function r(t, n, i, o, s, u) {
441
+ var c = e.call(this, t) || this;
442
+ return c.onFinalize = s, c.shouldUnsubscribe = u, c._next = n ? function(h) {
443
+ try {
444
+ n(h);
445
+ } catch (f) {
446
+ t.error(f);
447
+ }
448
+ } : e.prototype._next, c._error = o ? function(h) {
449
+ try {
450
+ o(h);
451
+ } catch (f) {
452
+ t.error(f);
453
+ } finally {
454
+ this.unsubscribe();
455
+ }
456
+ } : e.prototype._error, c._complete = i ? function() {
457
+ try {
458
+ i();
459
+ } catch (h) {
460
+ t.error(h);
461
+ } finally {
462
+ this.unsubscribe();
463
+ }
464
+ } : e.prototype._complete, c;
465
+ }
466
+ return r.prototype.unsubscribe = function() {
467
+ var t;
468
+ if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
469
+ var n = this.closed;
470
+ e.prototype.unsubscribe.call(this), !n && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
471
+ }
472
+ }, r;
473
+ }($), ht = H(function(e) {
474
+ return function() {
475
+ e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
476
+ };
477
+ }), v = function(e) {
478
+ d(r, e);
479
+ function r() {
480
+ var t = e.call(this) || this;
481
+ return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
482
+ }
483
+ return r.prototype.lift = function(t) {
484
+ var n = new M(this, this);
485
+ return n.operator = t, n;
486
+ }, r.prototype._throwIfClosed = function() {
487
+ if (this.closed)
488
+ throw new ht();
489
+ }, r.prototype.next = function(t) {
490
+ var n = this;
491
+ g(function() {
492
+ var i, o;
493
+ if (n._throwIfClosed(), !n.isStopped) {
494
+ n.currentObservers || (n.currentObservers = Array.from(n.observers));
495
+ try {
496
+ for (var s = A(n.currentObservers), u = s.next(); !u.done; u = s.next()) {
497
+ var c = u.value;
498
+ c.next(t);
499
+ }
500
+ } catch (h) {
501
+ i = { error: h };
502
+ } finally {
503
+ try {
504
+ u && !u.done && (o = s.return) && o.call(s);
505
+ } finally {
506
+ if (i)
507
+ throw i.error;
508
+ }
509
+ }
510
+ }
511
+ });
512
+ }, r.prototype.error = function(t) {
513
+ var n = this;
514
+ g(function() {
515
+ if (n._throwIfClosed(), !n.isStopped) {
516
+ n.hasError = n.isStopped = !0, n.thrownError = t;
517
+ for (var i = n.observers; i.length; )
518
+ i.shift().error(t);
519
+ }
520
+ });
521
+ }, r.prototype.complete = function() {
522
+ var t = this;
523
+ g(function() {
524
+ if (t._throwIfClosed(), !t.isStopped) {
525
+ t.isStopped = !0;
526
+ for (var n = t.observers; n.length; )
527
+ n.shift().complete();
528
+ }
529
+ });
530
+ }, r.prototype.unsubscribe = function() {
531
+ this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
532
+ }, Object.defineProperty(r.prototype, "observed", {
533
+ get: function() {
534
+ var t;
535
+ return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
536
+ },
537
+ enumerable: !1,
538
+ configurable: !0
539
+ }), r.prototype._trySubscribe = function(t) {
540
+ return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
541
+ }, r.prototype._subscribe = function(t) {
542
+ return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
543
+ }, r.prototype._innerSubscribe = function(t) {
544
+ var n = this, i = this, o = i.hasError, s = i.isStopped, u = i.observers;
545
+ return o || s ? L : (this.currentObservers = null, u.push(t), new E(function() {
546
+ n.currentObservers = null, j(u, t);
547
+ }));
548
+ }, r.prototype._checkFinalizedStatuses = function(t) {
549
+ var n = this, i = n.hasError, o = n.thrownError, s = n.isStopped;
550
+ i ? t.error(o) : s && t.complete();
551
+ }, r.prototype.asObservable = function() {
552
+ var t = new C();
553
+ return t.source = this, t;
554
+ }, r.create = function(t, n) {
555
+ return new M(t, n);
556
+ }, r;
557
+ }(C), M = function(e) {
558
+ d(r, e);
559
+ function r(t, n) {
560
+ var i = e.call(this) || this;
561
+ return i.destination = t, i.source = n, i;
562
+ }
563
+ return r.prototype.next = function(t) {
564
+ var n, i;
565
+ (i = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || i === void 0 || i.call(n, t);
566
+ }, r.prototype.error = function(t) {
567
+ var n, i;
568
+ (i = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || i === void 0 || i.call(n, t);
569
+ }, r.prototype.complete = function() {
570
+ var t, n;
571
+ (n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
572
+ }, r.prototype._subscribe = function(t) {
573
+ var n, i;
574
+ return (i = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && i !== void 0 ? i : L;
575
+ }, r;
576
+ }(v), ft = function(e) {
577
+ d(r, e);
578
+ function r(t) {
579
+ var n = e.call(this) || this;
580
+ return n._value = t, n;
581
+ }
582
+ return Object.defineProperty(r.prototype, "value", {
583
+ get: function() {
584
+ return this.getValue();
585
+ },
586
+ enumerable: !1,
587
+ configurable: !0
588
+ }), r.prototype._subscribe = function(t) {
589
+ var n = e.prototype._subscribe.call(this, t);
590
+ return !n.closed && t.next(this._value), n;
591
+ }, r.prototype.getValue = function() {
592
+ var t = this, n = t.hasError, i = t.thrownError, o = t._value;
593
+ if (n)
594
+ throw i;
595
+ return this._throwIfClosed(), o;
596
+ }, r.prototype.next = function(t) {
597
+ e.prototype.next.call(this, this._value = t);
598
+ }, r;
599
+ }(v), dt = new C(function(e) {
600
+ return e.complete();
601
+ });
602
+ function vt(e) {
603
+ return e <= 0 ? function() {
604
+ return dt;
605
+ } : at(function(r, t) {
606
+ var n = 0;
607
+ r.subscribe(lt(t, function(i) {
608
+ ++n <= e && (t.next(i), e <= n && t.complete());
609
+ }));
610
+ });
611
+ }
612
+ class bt {
613
+ constructor(r, t) {
614
+ this.id = r, this.entries$ = new ft([]), t.addEventListener("user-submit", (n) => {
615
+ if (!this.provider) {
616
+ console.warn(
617
+ "No provider activated, unable to print message to conversation."
618
+ );
619
+ return;
620
+ }
621
+ this.provider.onUserSubmit(n.detail);
622
+ });
623
+ }
624
+ write(r) {
625
+ this.entries$.pipe(vt(1)).subscribe((t) => {
626
+ this.entries$.next([...t, r]);
627
+ });
628
+ }
629
+ entries() {
630
+ return this.entries$.asObservable();
631
+ }
632
+ setProvider(r) {
633
+ this.provider = r, this.provider.actions().subscribe((t) => {
634
+ this.write(t);
635
+ });
636
+ }
637
+ }
638
+ class D {
639
+ constructor() {
640
+ this.sessions = /* @__PURE__ */ new Map(), this.registeredProviders = /* @__PURE__ */ new Map(), this.activeSessionId = null;
641
+ }
642
+ static async getInstance(r) {
643
+ let t = await r.get("conversation");
644
+ return t || (t = new D(), await r.register("conversation", t), t);
645
+ }
646
+ registerProvider(r, t) {
647
+ this.registeredProviders.set(r, t);
648
+ }
649
+ createSession(r) {
650
+ const t = new bt(X(), r), n = this.getProviderByConfiguration(r);
651
+ if (n) {
652
+ const i = n();
653
+ t.setProvider(i);
654
+ }
655
+ return this.sessions.set(t.id, t), this.activeSessionId = t.id, t;
656
+ }
657
+ getProviderByConfiguration(r) {
658
+ const [t] = r.properties.providers || [];
659
+ if (!t) {
660
+ console.warn(
661
+ "No providers registered. You most likely forgot to add a provider to the conversation component properties."
662
+ );
663
+ return;
664
+ }
665
+ return this.registeredProviders.get(t);
666
+ }
667
+ }
668
+ const St = async (e) => {
669
+ e.registerComponent("conversation", import("./conversation-863ede7a.mjs").then((r) => r.c)), await D.getInstance(e.container);
670
+ };
671
+ var x = /* @__PURE__ */ ((e) => (e.User = "user", e.Agent = "agent", e.System = "system", e))(x || {});
672
+ class F {
673
+ constructor(r, t, n) {
674
+ this.type = r, this.sender = t, this.messages = n, this.didUpdate = new v(), this.timestamp = Date.now();
675
+ }
676
+ update(r) {
677
+ this.messages = [
678
+ {
679
+ items: r
680
+ }
681
+ ], this.didUpdate.next(this);
682
+ }
683
+ }
684
+ class yt {
685
+ constructor(r) {
686
+ this.name = r, this.print$ = new v();
687
+ }
688
+ print(r) {
689
+ const t = new F(
690
+ x.Agent,
691
+ { name: this.name },
692
+ [
693
+ {
694
+ items: [["html", { content: r }]]
695
+ }
696
+ ]
697
+ );
698
+ return this.print$.next(t), t;
699
+ }
700
+ subscribe() {
701
+ return this.print$.asObservable();
702
+ }
703
+ }
704
+ class mt {
705
+ constructor(r) {
706
+ this.name = r, this.print$ = new v();
707
+ }
708
+ print(r) {
709
+ const t = new F(
710
+ x.User,
711
+ { name: this.name },
712
+ [
713
+ {
714
+ items: [["html", { content: r }]]
715
+ }
716
+ ]
717
+ );
718
+ return this.print$.next(t), t;
719
+ }
720
+ subscribe() {
721
+ return this.print$.asObservable();
722
+ }
723
+ }
724
+ class gt {
725
+ constructor(r) {
726
+ this.name = r, this.print$ = new v();
727
+ }
728
+ onUserSubmit(r) {
729
+ this.print(x.User, r.text);
730
+ }
731
+ print(r, t) {
732
+ const n = new F(
733
+ r,
734
+ {
735
+ name: "Botsson"
736
+ // TODO:
737
+ },
738
+ [
739
+ {
740
+ items: [["html", { content: t }]]
741
+ }
742
+ ]
743
+ );
744
+ return this.printEntry(n);
745
+ }
746
+ printEntry(r) {
747
+ return this.print$.next(r), r;
748
+ }
749
+ createAgent(r) {
750
+ const t = new yt(r);
751
+ return t.subscribe().subscribe((n) => {
752
+ this.printEntry(n);
753
+ }), t;
754
+ }
755
+ createUser(r) {
756
+ const t = new mt(r);
757
+ return t.subscribe().subscribe((n) => {
758
+ this.printEntry(n);
759
+ }), t;
760
+ }
761
+ actions() {
762
+ return this.print$.asObservable();
763
+ }
764
+ }
765
+ export {
766
+ yt as A,
767
+ x as C,
768
+ mt as U,
769
+ St as a,
770
+ D as b,
771
+ gt as c,
772
+ F as d
773
+ };