@asgard-js/core 0.0.2 → 0.0.3-8.canary-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.
Files changed (50) hide show
  1. package/README.md +329 -6
  2. package/dist/constants/enum.d.ts +11 -2
  3. package/dist/constants/enum.d.ts.map +1 -1
  4. package/dist/index.cjs +3 -3
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +876 -677
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/lib/channel.d.ts +19 -0
  13. package/dist/lib/channel.d.ts.map +1 -0
  14. package/dist/lib/client.d.ts +10 -6
  15. package/dist/lib/client.d.ts.map +1 -1
  16. package/dist/lib/conversation.d.ts +8 -19
  17. package/dist/lib/conversation.d.ts.map +1 -1
  18. package/dist/lib/create-sse-observable.d.ts +2 -1
  19. package/dist/lib/create-sse-observable.d.ts.map +1 -1
  20. package/dist/lib/event-emitter.d.ts +8 -0
  21. package/dist/lib/event-emitter.d.ts.map +1 -0
  22. package/dist/types/channel.d.ts +42 -0
  23. package/dist/types/channel.d.ts.map +1 -0
  24. package/dist/types/client.d.ts +55 -27
  25. package/dist/types/client.d.ts.map +1 -1
  26. package/dist/types/event-emitter.d.ts +5 -0
  27. package/dist/types/event-emitter.d.ts.map +1 -0
  28. package/dist/types/index.d.ts +2 -0
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/dist/types/sse-response.d.ts +56 -9
  31. package/dist/types/sse-response.d.ts.map +1 -1
  32. package/eslint.config.cjs +22 -0
  33. package/package.json +13 -1
  34. package/src/constants/enum.ts +32 -0
  35. package/src/index.ts +11 -0
  36. package/src/lib/channel.ts +153 -0
  37. package/src/lib/client.spec.ts +150 -0
  38. package/src/lib/client.ts +141 -0
  39. package/src/lib/conversation.ts +120 -0
  40. package/src/lib/create-sse-observable.ts +77 -0
  41. package/src/lib/event-emitter.ts +30 -0
  42. package/src/types/channel.ts +50 -0
  43. package/src/types/client.ts +89 -0
  44. package/src/types/event-emitter.ts +8 -0
  45. package/src/types/index.ts +4 -0
  46. package/src/types/sse-response.ts +176 -0
  47. package/tsconfig.json +13 -0
  48. package/tsconfig.lib.json +28 -0
  49. package/tsconfig.spec.json +33 -0
  50. package/vite.config.ts +80 -0
package/dist/index.mjs CHANGED
@@ -1,110 +1,110 @@
1
- var ke = Object.defineProperty;
2
- var Le = (n, t, e) => t in n ? ke(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var _ = (n, t, e) => Le(n, typeof t != "symbol" ? t + "" : t, e);
4
- var $ = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n))($ || {}), g = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.DONE = "asgard.run.done", n))(g || {}), Ne = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n))(Ne || {}), V = function(n, t) {
5
- return V = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
1
+ var De = Object.defineProperty;
2
+ var Ue = (n, t, e) => t in n ? De(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var m = (n, t, e) => Ue(n, typeof t != "symbol" ? t + "" : t, e);
4
+ var K = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n))(K || {}), h = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(h || {}), Ne = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n))(Ne || {}), Y = function(n, t) {
5
+ return Y = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
6
6
  e.__proto__ = r;
7
7
  } || function(e, r) {
8
8
  for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
9
- }, V(n, t);
9
+ }, Y(n, t);
10
10
  };
11
11
  function O(n, t) {
12
12
  if (typeof t != "function" && t !== null)
13
13
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
14
- V(n, t);
14
+ Y(n, t);
15
15
  function e() {
16
16
  this.constructor = n;
17
17
  }
18
18
  n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
19
19
  }
20
- function je(n, t, e, r) {
21
- function i(s) {
22
- return s instanceof e ? s : new e(function(o) {
23
- o(s);
20
+ function $e(n, t, e, r) {
21
+ function i(o) {
22
+ return o instanceof e ? o : new e(function(s) {
23
+ s(o);
24
24
  });
25
25
  }
26
- return new (e || (e = Promise))(function(s, o) {
27
- function c(l) {
26
+ return new (e || (e = Promise))(function(o, s) {
27
+ function c(f) {
28
28
  try {
29
- a(r.next(l));
30
- } catch (h) {
31
- o(h);
29
+ u(r.next(f));
30
+ } catch (y) {
31
+ s(y);
32
32
  }
33
33
  }
34
- function u(l) {
34
+ function a(f) {
35
35
  try {
36
- a(r.throw(l));
37
- } catch (h) {
38
- o(h);
36
+ u(r.throw(f));
37
+ } catch (y) {
38
+ s(y);
39
39
  }
40
40
  }
41
- function a(l) {
42
- l.done ? s(l.value) : i(l.value).then(c, u);
41
+ function u(f) {
42
+ f.done ? o(f.value) : i(f.value).then(c, a);
43
43
  }
44
- a((r = r.apply(n, t || [])).next());
44
+ u((r = r.apply(n, t || [])).next());
45
45
  });
46
46
  }
47
- function oe(n, t) {
47
+ function ce(n, t) {
48
48
  var e = { label: 0, sent: function() {
49
- if (s[0] & 1) throw s[1];
50
- return s[1];
51
- }, trys: [], ops: [] }, r, i, s, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
52
- return o.next = c(0), o.throw = c(1), o.return = c(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
49
+ if (o[0] & 1) throw o[1];
50
+ return o[1];
51
+ }, trys: [], ops: [] }, r, i, o, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
52
+ return s.next = c(0), s.throw = c(1), s.return = c(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
53
53
  return this;
54
- }), o;
55
- function c(a) {
56
- return function(l) {
57
- return u([a, l]);
54
+ }), s;
55
+ function c(u) {
56
+ return function(f) {
57
+ return a([u, f]);
58
58
  };
59
59
  }
60
- function u(a) {
60
+ function a(u) {
61
61
  if (r) throw new TypeError("Generator is already executing.");
62
- for (; o && (o = 0, a[0] && (e = 0)), e; ) try {
63
- if (r = 1, i && (s = a[0] & 2 ? i.return : a[0] ? i.throw || ((s = i.return) && s.call(i), 0) : i.next) && !(s = s.call(i, a[1])).done) return s;
64
- switch (i = 0, s && (a = [a[0] & 2, s.value]), a[0]) {
62
+ for (; s && (s = 0, u[0] && (e = 0)), e; ) try {
63
+ if (r = 1, i && (o = u[0] & 2 ? i.return : u[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, u[1])).done) return o;
64
+ switch (i = 0, o && (u = [u[0] & 2, o.value]), u[0]) {
65
65
  case 0:
66
66
  case 1:
67
- s = a;
67
+ o = u;
68
68
  break;
69
69
  case 4:
70
- return e.label++, { value: a[1], done: !1 };
70
+ return e.label++, { value: u[1], done: !1 };
71
71
  case 5:
72
- e.label++, i = a[1], a = [0];
72
+ e.label++, i = u[1], u = [0];
73
73
  continue;
74
74
  case 7:
75
- a = e.ops.pop(), e.trys.pop();
75
+ u = e.ops.pop(), e.trys.pop();
76
76
  continue;
77
77
  default:
78
- if (s = e.trys, !(s = s.length > 0 && s[s.length - 1]) && (a[0] === 6 || a[0] === 2)) {
78
+ if (o = e.trys, !(o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
79
79
  e = 0;
80
80
  continue;
81
81
  }
82
- if (a[0] === 3 && (!s || a[1] > s[0] && a[1] < s[3])) {
83
- e.label = a[1];
82
+ if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
83
+ e.label = u[1];
84
84
  break;
85
85
  }
86
- if (a[0] === 6 && e.label < s[1]) {
87
- e.label = s[1], s = a;
86
+ if (u[0] === 6 && e.label < o[1]) {
87
+ e.label = o[1], o = u;
88
88
  break;
89
89
  }
90
- if (s && e.label < s[2]) {
91
- e.label = s[2], e.ops.push(a);
90
+ if (o && e.label < o[2]) {
91
+ e.label = o[2], e.ops.push(u);
92
92
  break;
93
93
  }
94
- s[2] && e.ops.pop(), e.trys.pop();
94
+ o[2] && e.ops.pop(), e.trys.pop();
95
95
  continue;
96
96
  }
97
- a = t.call(n, e);
98
- } catch (l) {
99
- a = [6, l], i = 0;
97
+ u = t.call(n, e);
98
+ } catch (f) {
99
+ u = [6, f], i = 0;
100
100
  } finally {
101
- r = s = 0;
101
+ r = o = 0;
102
102
  }
103
- if (a[0] & 5) throw a[1];
104
- return { value: a[0] ? a[1] : void 0, done: !0 };
103
+ if (u[0] & 5) throw u[1];
104
+ return { value: u[0] ? u[1] : void 0, done: !0 };
105
105
  }
106
106
  }
107
- function P(n) {
107
+ function M(n) {
108
108
  var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
109
109
  if (e) return e.call(n);
110
110
  if (n && typeof n.length == "number") return {
@@ -114,98 +114,98 @@ function P(n) {
114
114
  };
115
115
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
116
116
  }
117
- function j(n, t) {
117
+ function L(n, t) {
118
118
  var e = typeof Symbol == "function" && n[Symbol.iterator];
119
119
  if (!e) return n;
120
- var r = e.call(n), i, s = [], o;
120
+ var r = e.call(n), i, o = [], s;
121
121
  try {
122
- for (; (t === void 0 || t-- > 0) && !(i = r.next()).done; ) s.push(i.value);
122
+ for (; (t === void 0 || t-- > 0) && !(i = r.next()).done; ) o.push(i.value);
123
123
  } catch (c) {
124
- o = { error: c };
124
+ s = { error: c };
125
125
  } finally {
126
126
  try {
127
127
  i && !i.done && (e = r.return) && e.call(r);
128
128
  } finally {
129
- if (o) throw o.error;
129
+ if (s) throw s.error;
130
130
  }
131
131
  }
132
- return s;
132
+ return o;
133
133
  }
134
134
  function R(n, t, e) {
135
- if (e || arguments.length === 2) for (var r = 0, i = t.length, s; r < i; r++)
136
- (s || !(r in t)) && (s || (s = Array.prototype.slice.call(t, 0, r)), s[r] = t[r]);
137
- return n.concat(s || Array.prototype.slice.call(t));
135
+ if (e || arguments.length === 2) for (var r = 0, i = t.length, o; r < i; r++)
136
+ (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
137
+ return n.concat(o || Array.prototype.slice.call(t));
138
138
  }
139
- function C(n) {
140
- return this instanceof C ? (this.v = n, this) : new C(n);
139
+ function P(n) {
140
+ return this instanceof P ? (this.v = n, this) : new P(n);
141
141
  }
142
- function Re(n, t, e) {
142
+ function Ge(n, t, e) {
143
143
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
144
- var r = e.apply(n, t || []), i, s = [];
145
- return i = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), c("next"), c("throw"), c("return", o), i[Symbol.asyncIterator] = function() {
144
+ var r = e.apply(n, t || []), i, o = [];
145
+ return i = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), c("next"), c("throw"), c("return", s), i[Symbol.asyncIterator] = function() {
146
146
  return this;
147
147
  }, i;
148
- function o(f) {
149
- return function(y) {
150
- return Promise.resolve(y).then(f, h);
148
+ function s(l) {
149
+ return function(v) {
150
+ return Promise.resolve(v).then(l, y);
151
151
  };
152
152
  }
153
- function c(f, y) {
154
- r[f] && (i[f] = function(d) {
155
- return new Promise(function(m, S) {
156
- s.push([f, d, m, S]) > 1 || u(f, d);
153
+ function c(l, v) {
154
+ r[l] && (i[l] = function(d) {
155
+ return new Promise(function(g, w) {
156
+ o.push([l, d, g, w]) > 1 || a(l, d);
157
157
  });
158
- }, y && (i[f] = y(i[f])));
158
+ }, v && (i[l] = v(i[l])));
159
159
  }
160
- function u(f, y) {
160
+ function a(l, v) {
161
161
  try {
162
- a(r[f](y));
162
+ u(r[l](v));
163
163
  } catch (d) {
164
- p(s[0][3], d);
164
+ b(o[0][3], d);
165
165
  }
166
166
  }
167
- function a(f) {
168
- f.value instanceof C ? Promise.resolve(f.value.v).then(l, h) : p(s[0][2], f);
167
+ function u(l) {
168
+ l.value instanceof P ? Promise.resolve(l.value.v).then(f, y) : b(o[0][2], l);
169
169
  }
170
- function l(f) {
171
- u("next", f);
170
+ function f(l) {
171
+ a("next", l);
172
172
  }
173
- function h(f) {
174
- u("throw", f);
173
+ function y(l) {
174
+ a("throw", l);
175
175
  }
176
- function p(f, y) {
177
- f(y), s.shift(), s.length && u(s[0][0], s[0][1]);
176
+ function b(l, v) {
177
+ l(v), o.shift(), o.length && a(o[0][0], o[0][1]);
178
178
  }
179
179
  }
180
- function Ue(n) {
180
+ function Fe(n) {
181
181
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
182
182
  var t = n[Symbol.asyncIterator], e;
183
- return t ? t.call(n) : (n = typeof P == "function" ? P(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
183
+ return t ? t.call(n) : (n = typeof M == "function" ? M(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
184
184
  return this;
185
185
  }, e);
186
- function r(s) {
187
- e[s] = n[s] && function(o) {
188
- return new Promise(function(c, u) {
189
- o = n[s](o), i(c, u, o.done, o.value);
186
+ function r(o) {
187
+ e[o] = n[o] && function(s) {
188
+ return new Promise(function(c, a) {
189
+ s = n[o](s), i(c, a, s.done, s.value);
190
190
  });
191
191
  };
192
192
  }
193
- function i(s, o, c, u) {
194
- Promise.resolve(u).then(function(a) {
195
- s({ value: a, done: c });
196
- }, o);
193
+ function i(o, s, c, a) {
194
+ Promise.resolve(a).then(function(u) {
195
+ o({ value: u, done: c });
196
+ }, s);
197
197
  }
198
198
  }
199
- function v(n) {
199
+ function p(n) {
200
200
  return typeof n == "function";
201
201
  }
202
- function ue(n) {
202
+ function fe(n) {
203
203
  var t = function(r) {
204
204
  Error.call(r), r.stack = new Error().stack;
205
205
  }, e = n(t);
206
206
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
207
207
  }
208
- var H = ue(function(n) {
208
+ var B = fe(function(n) {
209
209
  return function(e) {
210
210
  n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
211
211
  ` + e.map(function(r, i) {
@@ -214,76 +214,76 @@ var H = ue(function(n) {
214
214
  `) : "", this.name = "UnsubscriptionError", this.errors = e;
215
215
  };
216
216
  });
217
- function U(n, t) {
217
+ function N(n, t) {
218
218
  if (n) {
219
219
  var e = n.indexOf(t);
220
220
  0 <= e && n.splice(e, 1);
221
221
  }
222
222
  }
223
- var D = function() {
223
+ var k = function() {
224
224
  function n(t) {
225
225
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
226
226
  }
227
227
  return n.prototype.unsubscribe = function() {
228
- var t, e, r, i, s;
228
+ var t, e, r, i, o;
229
229
  if (!this.closed) {
230
230
  this.closed = !0;
231
- var o = this._parentage;
232
- if (o)
233
- if (this._parentage = null, Array.isArray(o))
231
+ var s = this._parentage;
232
+ if (s)
233
+ if (this._parentage = null, Array.isArray(s))
234
234
  try {
235
- for (var c = P(o), u = c.next(); !u.done; u = c.next()) {
236
- var a = u.value;
237
- a.remove(this);
235
+ for (var c = M(s), a = c.next(); !a.done; a = c.next()) {
236
+ var u = a.value;
237
+ u.remove(this);
238
238
  }
239
239
  } catch (d) {
240
240
  t = { error: d };
241
241
  } finally {
242
242
  try {
243
- u && !u.done && (e = c.return) && e.call(c);
243
+ a && !a.done && (e = c.return) && e.call(c);
244
244
  } finally {
245
245
  if (t) throw t.error;
246
246
  }
247
247
  }
248
248
  else
249
- o.remove(this);
250
- var l = this.initialTeardown;
251
- if (v(l))
249
+ s.remove(this);
250
+ var f = this.initialTeardown;
251
+ if (p(f))
252
252
  try {
253
- l();
253
+ f();
254
254
  } catch (d) {
255
- s = d instanceof H ? d.errors : [d];
255
+ o = d instanceof B ? d.errors : [d];
256
256
  }
257
- var h = this._finalizers;
258
- if (h) {
257
+ var y = this._finalizers;
258
+ if (y) {
259
259
  this._finalizers = null;
260
260
  try {
261
- for (var p = P(h), f = p.next(); !f.done; f = p.next()) {
262
- var y = f.value;
261
+ for (var b = M(y), l = b.next(); !l.done; l = b.next()) {
262
+ var v = l.value;
263
263
  try {
264
- z(y);
264
+ ee(v);
265
265
  } catch (d) {
266
- s = s ?? [], d instanceof H ? s = R(R([], j(s)), j(d.errors)) : s.push(d);
266
+ o = o ?? [], d instanceof B ? o = R(R([], L(o)), L(d.errors)) : o.push(d);
267
267
  }
268
268
  }
269
269
  } catch (d) {
270
270
  r = { error: d };
271
271
  } finally {
272
272
  try {
273
- f && !f.done && (i = p.return) && i.call(p);
273
+ l && !l.done && (i = b.return) && i.call(b);
274
274
  } finally {
275
275
  if (r) throw r.error;
276
276
  }
277
277
  }
278
278
  }
279
- if (s)
280
- throw new H(s);
279
+ if (o)
280
+ throw new B(o);
281
281
  }
282
282
  }, n.prototype.add = function(t) {
283
283
  var e;
284
284
  if (t && t !== this)
285
285
  if (this.closed)
286
- z(t);
286
+ ee(t);
287
287
  else {
288
288
  if (t instanceof n) {
289
289
  if (t.closed || t._hasParent(this))
@@ -300,57 +300,57 @@ var D = function() {
300
300
  this._parentage = Array.isArray(e) ? (e.push(t), e) : e ? [e, t] : t;
301
301
  }, n.prototype._removeParent = function(t) {
302
302
  var e = this._parentage;
303
- e === t ? this._parentage = null : Array.isArray(e) && U(e, t);
303
+ e === t ? this._parentage = null : Array.isArray(e) && N(e, t);
304
304
  }, n.prototype.remove = function(t) {
305
305
  var e = this._finalizers;
306
- e && U(e, t), t instanceof n && t._removeParent(this);
306
+ e && N(e, t), t instanceof n && t._removeParent(this);
307
307
  }, n.EMPTY = function() {
308
308
  var t = new n();
309
309
  return t.closed = !0, t;
310
310
  }(), n;
311
- }(), ae = D.EMPTY;
312
- function ce(n) {
313
- return n instanceof D || n && "closed" in n && v(n.remove) && v(n.add) && v(n.unsubscribe);
311
+ }(), le = k.EMPTY;
312
+ function de(n) {
313
+ return n instanceof k || n && "closed" in n && p(n.remove) && p(n.add) && p(n.unsubscribe);
314
314
  }
315
- function z(n) {
316
- v(n) ? n() : n.unsubscribe();
315
+ function ee(n) {
316
+ p(n) ? n() : n.unsubscribe();
317
317
  }
318
- var Ge = {
318
+ var He = {
319
319
  onUnhandledError: null,
320
320
  onStoppedNotification: null,
321
321
  Promise: void 0,
322
322
  useDeprecatedSynchronousErrorHandling: !1,
323
323
  useDeprecatedNextContext: !1
324
- }, fe = {
324
+ }, he = {
325
325
  setTimeout: function(n, t) {
326
326
  for (var e = [], r = 2; r < arguments.length; r++)
327
327
  e[r - 2] = arguments[r];
328
- return setTimeout.apply(void 0, R([n, t], j(e)));
328
+ return setTimeout.apply(void 0, R([n, t], L(e)));
329
329
  },
330
330
  clearTimeout: function(n) {
331
- var t = fe.delegate;
331
+ var t = he.delegate;
332
332
  return ((t == null ? void 0 : t.clearTimeout) || clearTimeout)(n);
333
333
  },
334
334
  delegate: void 0
335
335
  };
336
- function le(n) {
337
- fe.setTimeout(function() {
336
+ function ye(n) {
337
+ he.setTimeout(function() {
338
338
  throw n;
339
339
  });
340
340
  }
341
- function Y() {
341
+ function q() {
342
342
  }
343
- function N(n) {
343
+ function U(n) {
344
344
  n();
345
345
  }
346
- var W = function(n) {
346
+ var X = function(n) {
347
347
  O(t, n);
348
348
  function t(e) {
349
349
  var r = n.call(this) || this;
350
- return r.isStopped = !1, e ? (r.destination = e, ce(e) && e.add(r)) : r.destination = He, r;
350
+ return r.isStopped = !1, e ? (r.destination = e, de(e) && e.add(r)) : r.destination = Ke, r;
351
351
  }
352
352
  return t.create = function(e, r, i) {
353
- return new q(e, r, i);
353
+ return new W(e, r, i);
354
354
  }, t.prototype.next = function(e) {
355
355
  this.isStopped || this._next(e);
356
356
  }, t.prototype.error = function(e) {
@@ -374,7 +374,7 @@ var W = function(n) {
374
374
  this.unsubscribe();
375
375
  }
376
376
  }, t;
377
- }(D), Fe = function() {
377
+ }(k), Ve = function() {
378
378
  function n(t) {
379
379
  this.partialObserver = t;
380
380
  }
@@ -384,7 +384,7 @@ var W = function(n) {
384
384
  try {
385
385
  e.next(t);
386
386
  } catch (r) {
387
- L(r);
387
+ D(r);
388
388
  }
389
389
  }, n.prototype.error = function(t) {
390
390
  var e = this.partialObserver;
@@ -392,56 +392,56 @@ var W = function(n) {
392
392
  try {
393
393
  e.error(t);
394
394
  } catch (r) {
395
- L(r);
395
+ D(r);
396
396
  }
397
397
  else
398
- L(t);
398
+ D(t);
399
399
  }, n.prototype.complete = function() {
400
400
  var t = this.partialObserver;
401
401
  if (t.complete)
402
402
  try {
403
403
  t.complete();
404
404
  } catch (e) {
405
- L(e);
405
+ D(e);
406
406
  }
407
407
  }, n;
408
- }(), q = function(n) {
408
+ }(), W = function(n) {
409
409
  O(t, n);
410
410
  function t(e, r, i) {
411
- var s = n.call(this) || this, o;
412
- return v(e) || !e ? o = {
411
+ var o = n.call(this) || this, s;
412
+ return p(e) || !e ? s = {
413
413
  next: e ?? void 0,
414
414
  error: r ?? void 0,
415
415
  complete: i ?? void 0
416
- } : o = e, s.destination = new Fe(o), s;
416
+ } : s = e, o.destination = new Ve(s), o;
417
417
  }
418
418
  return t;
419
- }(W);
420
- function L(n) {
421
- le(n);
419
+ }(X);
420
+ function D(n) {
421
+ ye(n);
422
422
  }
423
- function Ke(n) {
423
+ function Be(n) {
424
424
  throw n;
425
425
  }
426
- var He = {
426
+ var Ke = {
427
427
  closed: !0,
428
- next: Y,
429
- error: Ke,
430
- complete: Y
431
- }, X = function() {
428
+ next: q,
429
+ error: Be,
430
+ complete: q
431
+ }, z = function() {
432
432
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
433
433
  }();
434
- function de(n) {
434
+ function G(n) {
435
435
  return n;
436
436
  }
437
- function $e(n) {
438
- return n.length === 0 ? de : n.length === 1 ? n[0] : function(e) {
437
+ function Ye(n) {
438
+ return n.length === 0 ? G : n.length === 1 ? n[0] : function(e) {
439
439
  return n.reduce(function(r, i) {
440
440
  return i(r);
441
441
  }, e);
442
442
  };
443
443
  }
444
- var b = function() {
444
+ var S = function() {
445
445
  function n(t) {
446
446
  t && (this._subscribe = t);
447
447
  }
@@ -449,11 +449,11 @@ var b = function() {
449
449
  var e = new n();
450
450
  return e.source = this, e.operator = t, e;
451
451
  }, n.prototype.subscribe = function(t, e, r) {
452
- var i = this, s = Ye(t) ? t : new q(t, e, r);
453
- return N(function() {
454
- var o = i, c = o.operator, u = o.source;
455
- s.add(c ? c.call(s, u) : u ? i._subscribe(s) : i._trySubscribe(s));
456
- }), s;
452
+ var i = this, o = We(t) ? t : new W(t, e, r);
453
+ return U(function() {
454
+ var s = i, c = s.operator, a = s.source;
455
+ o.add(c ? c.call(o, a) : a ? i._subscribe(o) : i._trySubscribe(o));
456
+ }), o;
457
457
  }, n.prototype._trySubscribe = function(t) {
458
458
  try {
459
459
  return this._subscribe(t);
@@ -462,61 +462,61 @@ var b = function() {
462
462
  }
463
463
  }, n.prototype.forEach = function(t, e) {
464
464
  var r = this;
465
- return e = J(e), new e(function(i, s) {
466
- var o = new q({
465
+ return e = te(e), new e(function(i, o) {
466
+ var s = new W({
467
467
  next: function(c) {
468
468
  try {
469
469
  t(c);
470
- } catch (u) {
471
- s(u), o.unsubscribe();
470
+ } catch (a) {
471
+ o(a), s.unsubscribe();
472
472
  }
473
473
  },
474
- error: s,
474
+ error: o,
475
475
  complete: i
476
476
  });
477
- r.subscribe(o);
477
+ r.subscribe(s);
478
478
  });
479
479
  }, n.prototype._subscribe = function(t) {
480
480
  var e;
481
481
  return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
482
- }, n.prototype[X] = function() {
482
+ }, n.prototype[z] = function() {
483
483
  return this;
484
484
  }, n.prototype.pipe = function() {
485
485
  for (var t = [], e = 0; e < arguments.length; e++)
486
486
  t[e] = arguments[e];
487
- return $e(t)(this);
487
+ return Ye(t)(this);
488
488
  }, n.prototype.toPromise = function(t) {
489
489
  var e = this;
490
- return t = J(t), new t(function(r, i) {
491
- var s;
492
- e.subscribe(function(o) {
493
- return s = o;
494
- }, function(o) {
495
- return i(o);
490
+ return t = te(t), new t(function(r, i) {
491
+ var o;
492
+ e.subscribe(function(s) {
493
+ return o = s;
494
+ }, function(s) {
495
+ return i(s);
496
496
  }, function() {
497
- return r(s);
497
+ return r(o);
498
498
  });
499
499
  });
500
500
  }, n.create = function(t) {
501
501
  return new n(t);
502
502
  }, n;
503
503
  }();
504
- function J(n) {
504
+ function te(n) {
505
505
  var t;
506
- return (t = n ?? Ge.Promise) !== null && t !== void 0 ? t : Promise;
506
+ return (t = n ?? He.Promise) !== null && t !== void 0 ? t : Promise;
507
507
  }
508
- function Ve(n) {
509
- return n && v(n.next) && v(n.error) && v(n.complete);
508
+ function qe(n) {
509
+ return n && p(n.next) && p(n.error) && p(n.complete);
510
510
  }
511
- function Ye(n) {
512
- return n && n instanceof W || Ve(n) && ce(n);
511
+ function We(n) {
512
+ return n && n instanceof X || qe(n) && de(n);
513
513
  }
514
- function qe(n) {
515
- return v(n == null ? void 0 : n.lift);
514
+ function Je(n) {
515
+ return p(n == null ? void 0 : n.lift);
516
516
  }
517
517
  function T(n) {
518
518
  return function(t) {
519
- if (qe(t))
519
+ if (Je(t))
520
520
  return t.lift(function(e) {
521
521
  try {
522
522
  return n(e, this);
@@ -527,36 +527,36 @@ function T(n) {
527
527
  throw new TypeError("Unable to lift unknown Observable type");
528
528
  };
529
529
  }
530
- function I(n, t, e, r, i) {
531
- return new Be(n, t, e, r, i);
530
+ function E(n, t, e, r, i) {
531
+ return new Xe(n, t, e, r, i);
532
532
  }
533
- var Be = function(n) {
533
+ var Xe = function(n) {
534
534
  O(t, n);
535
- function t(e, r, i, s, o, c) {
536
- var u = n.call(this, e) || this;
537
- return u.onFinalize = o, u.shouldUnsubscribe = c, u._next = r ? function(a) {
535
+ function t(e, r, i, o, s, c) {
536
+ var a = n.call(this, e) || this;
537
+ return a.onFinalize = s, a.shouldUnsubscribe = c, a._next = r ? function(u) {
538
538
  try {
539
- r(a);
540
- } catch (l) {
541
- e.error(l);
539
+ r(u);
540
+ } catch (f) {
541
+ e.error(f);
542
542
  }
543
- } : n.prototype._next, u._error = s ? function(a) {
543
+ } : n.prototype._next, a._error = o ? function(u) {
544
544
  try {
545
- s(a);
546
- } catch (l) {
547
- e.error(l);
545
+ o(u);
546
+ } catch (f) {
547
+ e.error(f);
548
548
  } finally {
549
549
  this.unsubscribe();
550
550
  }
551
- } : n.prototype._error, u._complete = i ? function() {
551
+ } : n.prototype._error, a._complete = i ? function() {
552
552
  try {
553
553
  i();
554
- } catch (a) {
555
- e.error(a);
554
+ } catch (u) {
555
+ e.error(u);
556
556
  } finally {
557
557
  this.unsubscribe();
558
558
  }
559
- } : n.prototype._complete, u;
559
+ } : n.prototype._complete, a;
560
560
  }
561
561
  return t.prototype.unsubscribe = function() {
562
562
  var e;
@@ -565,38 +565,38 @@ var Be = function(n) {
565
565
  n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
566
566
  }
567
567
  }, t;
568
- }(W), We = ue(function(n) {
568
+ }(X), ze = fe(function(n) {
569
569
  return function() {
570
570
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
571
571
  };
572
- }), he = function(n) {
572
+ }), Q = function(n) {
573
573
  O(t, n);
574
574
  function t() {
575
575
  var e = n.call(this) || this;
576
576
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
577
577
  }
578
578
  return t.prototype.lift = function(e) {
579
- var r = new Q(this, this);
579
+ var r = new ne(this, this);
580
580
  return r.operator = e, r;
581
581
  }, t.prototype._throwIfClosed = function() {
582
582
  if (this.closed)
583
- throw new We();
583
+ throw new ze();
584
584
  }, t.prototype.next = function(e) {
585
585
  var r = this;
586
- N(function() {
587
- var i, s;
586
+ U(function() {
587
+ var i, o;
588
588
  if (r._throwIfClosed(), !r.isStopped) {
589
589
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
590
590
  try {
591
- for (var o = P(r.currentObservers), c = o.next(); !c.done; c = o.next()) {
592
- var u = c.value;
593
- u.next(e);
591
+ for (var s = M(r.currentObservers), c = s.next(); !c.done; c = s.next()) {
592
+ var a = c.value;
593
+ a.next(e);
594
594
  }
595
- } catch (a) {
596
- i = { error: a };
595
+ } catch (u) {
596
+ i = { error: u };
597
597
  } finally {
598
598
  try {
599
- c && !c.done && (s = o.return) && s.call(o);
599
+ c && !c.done && (o = s.return) && o.call(s);
600
600
  } finally {
601
601
  if (i) throw i.error;
602
602
  }
@@ -605,7 +605,7 @@ var Be = function(n) {
605
605
  });
606
606
  }, t.prototype.error = function(e) {
607
607
  var r = this;
608
- N(function() {
608
+ U(function() {
609
609
  if (r._throwIfClosed(), !r.isStopped) {
610
610
  r.hasError = r.isStopped = !0, r.thrownError = e;
611
611
  for (var i = r.observers; i.length; )
@@ -614,7 +614,7 @@ var Be = function(n) {
614
614
  });
615
615
  }, t.prototype.complete = function() {
616
616
  var e = this;
617
- N(function() {
617
+ U(function() {
618
618
  if (e._throwIfClosed(), !e.isStopped) {
619
619
  e.isStopped = !0;
620
620
  for (var r = e.observers; r.length; )
@@ -635,20 +635,20 @@ var Be = function(n) {
635
635
  }, t.prototype._subscribe = function(e) {
636
636
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
637
637
  }, t.prototype._innerSubscribe = function(e) {
638
- var r = this, i = this, s = i.hasError, o = i.isStopped, c = i.observers;
639
- return s || o ? ae : (this.currentObservers = null, c.push(e), new D(function() {
640
- r.currentObservers = null, U(c, e);
638
+ var r = this, i = this, o = i.hasError, s = i.isStopped, c = i.observers;
639
+ return o || s ? le : (this.currentObservers = null, c.push(e), new k(function() {
640
+ r.currentObservers = null, N(c, e);
641
641
  }));
642
642
  }, t.prototype._checkFinalizedStatuses = function(e) {
643
- var r = this, i = r.hasError, s = r.thrownError, o = r.isStopped;
644
- i ? e.error(s) : o && e.complete();
643
+ var r = this, i = r.hasError, o = r.thrownError, s = r.isStopped;
644
+ i ? e.error(o) : s && e.complete();
645
645
  }, t.prototype.asObservable = function() {
646
- var e = new b();
646
+ var e = new S();
647
647
  return e.source = this, e;
648
648
  }, t.create = function(e, r) {
649
- return new Q(e, r);
649
+ return new ne(e, r);
650
650
  }, t;
651
- }(b), Q = function(n) {
651
+ }(S), ne = function(n) {
652
652
  O(t, n);
653
653
  function t(e, r) {
654
654
  var i = n.call(this) || this;
@@ -665,14 +665,37 @@ var Be = function(n) {
665
665
  (r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
666
666
  }, t.prototype._subscribe = function(e) {
667
667
  var r, i;
668
- return (i = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && i !== void 0 ? i : ae;
668
+ return (i = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && i !== void 0 ? i : le;
669
+ }, t;
670
+ }(Q), re = function(n) {
671
+ O(t, n);
672
+ function t(e) {
673
+ var r = n.call(this) || this;
674
+ return r._value = e, r;
675
+ }
676
+ return Object.defineProperty(t.prototype, "value", {
677
+ get: function() {
678
+ return this.getValue();
679
+ },
680
+ enumerable: !1,
681
+ configurable: !0
682
+ }), t.prototype._subscribe = function(e) {
683
+ var r = n.prototype._subscribe.call(this, e);
684
+ return !r.closed && e.next(this._value), r;
685
+ }, t.prototype.getValue = function() {
686
+ var e = this, r = e.hasError, i = e.thrownError, o = e._value;
687
+ if (r)
688
+ throw i;
689
+ return this._throwIfClosed(), o;
690
+ }, t.prototype.next = function(e) {
691
+ n.prototype.next.call(this, this._value = e);
669
692
  }, t;
670
- }(he), Xe = {
693
+ }(Q), Qe = {
671
694
  now: function() {
672
695
  return Date.now();
673
696
  },
674
697
  delegate: void 0
675
- }, ze = function(n) {
698
+ }, Ze = function(n) {
676
699
  O(t, n);
677
700
  function t(e, r) {
678
701
  return n.call(this) || this;
@@ -680,17 +703,17 @@ var Be = function(n) {
680
703
  return t.prototype.schedule = function(e, r) {
681
704
  return this;
682
705
  }, t;
683
- }(D), Z = {
706
+ }(k), ie = {
684
707
  setInterval: function(n, t) {
685
708
  for (var e = [], r = 2; r < arguments.length; r++)
686
709
  e[r - 2] = arguments[r];
687
- return setInterval.apply(void 0, R([n, t], j(e)));
710
+ return setInterval.apply(void 0, R([n, t], L(e)));
688
711
  },
689
712
  clearInterval: function(n) {
690
713
  return clearInterval(n);
691
714
  },
692
715
  delegate: void 0
693
- }, Je = function(n) {
716
+ }, et = function(n) {
694
717
  O(t, n);
695
718
  function t(e, r) {
696
719
  var i = n.call(this, e, r) || this;
@@ -701,14 +724,14 @@ var Be = function(n) {
701
724
  if (r === void 0 && (r = 0), this.closed)
702
725
  return this;
703
726
  this.state = e;
704
- var s = this.id, o = this.scheduler;
705
- return s != null && (this.id = this.recycleAsyncId(o, s, r)), this.pending = !0, this.delay = r, this.id = (i = this.id) !== null && i !== void 0 ? i : this.requestAsyncId(o, this.id, r), this;
727
+ var o = this.id, s = this.scheduler;
728
+ return o != null && (this.id = this.recycleAsyncId(s, o, r)), this.pending = !0, this.delay = r, this.id = (i = this.id) !== null && i !== void 0 ? i : this.requestAsyncId(s, this.id, r), this;
706
729
  }, t.prototype.requestAsyncId = function(e, r, i) {
707
- return i === void 0 && (i = 0), Z.setInterval(e.flush.bind(e, this), i);
730
+ return i === void 0 && (i = 0), ie.setInterval(e.flush.bind(e, this), i);
708
731
  }, t.prototype.recycleAsyncId = function(e, r, i) {
709
732
  if (i === void 0 && (i = 0), i != null && this.delay === i && this.pending === !1)
710
733
  return r;
711
- r != null && Z.clearInterval(r);
734
+ r != null && ie.clearInterval(r);
712
735
  }, t.prototype.execute = function(e, r) {
713
736
  if (this.closed)
714
737
  return new Error("executing a cancelled action");
@@ -718,31 +741,31 @@ var Be = function(n) {
718
741
  return i;
719
742
  this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
720
743
  }, t.prototype._execute = function(e, r) {
721
- var i = !1, s;
744
+ var i = !1, o;
722
745
  try {
723
746
  this.work(e);
724
- } catch (o) {
725
- i = !0, s = o || new Error("Scheduled action threw falsy error");
747
+ } catch (s) {
748
+ i = !0, o = s || new Error("Scheduled action threw falsy error");
726
749
  }
727
750
  if (i)
728
- return this.unsubscribe(), s;
751
+ return this.unsubscribe(), o;
729
752
  }, t.prototype.unsubscribe = function() {
730
753
  if (!this.closed) {
731
- var e = this, r = e.id, i = e.scheduler, s = i.actions;
732
- this.work = this.state = this.scheduler = null, this.pending = !1, U(s, this), r != null && (this.id = this.recycleAsyncId(i, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
754
+ var e = this, r = e.id, i = e.scheduler, o = i.actions;
755
+ this.work = this.state = this.scheduler = null, this.pending = !1, N(o, this), r != null && (this.id = this.recycleAsyncId(i, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
733
756
  }
734
757
  }, t;
735
- }(ze), ee = function() {
758
+ }(Ze), oe = function() {
736
759
  function n(t, e) {
737
760
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
738
761
  }
739
762
  return n.prototype.schedule = function(t, e, r) {
740
763
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
741
- }, n.now = Xe.now, n;
742
- }(), Qe = function(n) {
764
+ }, n.now = Qe.now, n;
765
+ }(), tt = function(n) {
743
766
  O(t, n);
744
767
  function t(e, r) {
745
- r === void 0 && (r = ee.now);
768
+ r === void 0 && (r = oe.now);
746
769
  var i = n.call(this, e, r) || this;
747
770
  return i.actions = [], i._active = !1, i;
748
771
  }
@@ -764,61 +787,64 @@ var Be = function(n) {
764
787
  throw i;
765
788
  }
766
789
  }, t;
767
- }(ee), ye = new Qe(Je), Ze = ye, en = new b(function(n) {
790
+ }(oe), ve = new tt(et), nt = ve, rt = new S(function(n) {
768
791
  return n.complete();
769
792
  });
770
- function ve(n) {
771
- return n && v(n.schedule);
793
+ function pe(n) {
794
+ return n && p(n.schedule);
772
795
  }
773
- function nn(n) {
796
+ function be(n) {
774
797
  return n[n.length - 1];
775
798
  }
776
- function tn(n) {
777
- return ve(nn(n)) ? n.pop() : void 0;
778
- }
779
- var pe = function(n) {
780
- return n && typeof n.length == "number" && typeof n != "function";
781
- };
782
- function be(n) {
783
- return v(n == null ? void 0 : n.then);
799
+ function it(n) {
800
+ return p(be(n)) ? n.pop() : void 0;
784
801
  }
785
802
  function me(n) {
786
- return v(n[X]);
803
+ return pe(be(n)) ? n.pop() : void 0;
787
804
  }
805
+ var Se = function(n) {
806
+ return n && typeof n.length == "number" && typeof n != "function";
807
+ };
788
808
  function ge(n) {
789
- return Symbol.asyncIterator && v(n == null ? void 0 : n[Symbol.asyncIterator]);
809
+ return p(n == null ? void 0 : n.then);
790
810
  }
791
811
  function we(n) {
812
+ return p(n[z]);
813
+ }
814
+ function Ee(n) {
815
+ return Symbol.asyncIterator && p(n == null ? void 0 : n[Symbol.asyncIterator]);
816
+ }
817
+ function Oe(n) {
792
818
  return new TypeError("You provided " + (n !== null && typeof n == "object" ? "an invalid object" : "'" + n + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
793
819
  }
794
- function rn() {
820
+ function ot() {
795
821
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
796
822
  }
797
- var Se = rn();
798
- function Ee(n) {
799
- return v(n == null ? void 0 : n[Se]);
823
+ var Ie = ot();
824
+ function Ae(n) {
825
+ return p(n == null ? void 0 : n[Ie]);
800
826
  }
801
- function Ie(n) {
802
- return Re(this, arguments, function() {
803
- var e, r, i, s;
804
- return oe(this, function(o) {
805
- switch (o.label) {
827
+ function xe(n) {
828
+ return Ge(this, arguments, function() {
829
+ var e, r, i, o;
830
+ return ce(this, function(s) {
831
+ switch (s.label) {
806
832
  case 0:
807
- e = n.getReader(), o.label = 1;
833
+ e = n.getReader(), s.label = 1;
808
834
  case 1:
809
- o.trys.push([1, , 9, 10]), o.label = 2;
835
+ s.trys.push([1, , 9, 10]), s.label = 2;
810
836
  case 2:
811
- return [4, C(e.read())];
837
+ return [4, P(e.read())];
812
838
  case 3:
813
- return r = o.sent(), i = r.value, s = r.done, s ? [4, C(void 0)] : [3, 5];
839
+ return r = s.sent(), i = r.value, o = r.done, o ? [4, P(void 0)] : [3, 5];
814
840
  case 4:
815
- return [2, o.sent()];
841
+ return [2, s.sent()];
816
842
  case 5:
817
- return [4, C(i)];
843
+ return [4, P(i)];
818
844
  case 6:
819
- return [4, o.sent()];
845
+ return [4, s.sent()];
820
846
  case 7:
821
- return o.sent(), [3, 2];
847
+ return s.sent(), [3, 2];
822
848
  case 8:
823
849
  return [3, 10];
824
850
  case 9:
@@ -829,66 +855,66 @@ function Ie(n) {
829
855
  });
830
856
  });
831
857
  }
832
- function Oe(n) {
833
- return v(n == null ? void 0 : n.getReader);
858
+ function _e(n) {
859
+ return p(n == null ? void 0 : n.getReader);
834
860
  }
835
861
  function x(n) {
836
- if (n instanceof b)
862
+ if (n instanceof S)
837
863
  return n;
838
864
  if (n != null) {
839
- if (me(n))
840
- return sn(n);
841
- if (pe(n))
842
- return on(n);
843
- if (be(n))
844
- return un(n);
865
+ if (we(n))
866
+ return st(n);
867
+ if (Se(n))
868
+ return ut(n);
845
869
  if (ge(n))
846
- return xe(n);
870
+ return at(n);
847
871
  if (Ee(n))
848
- return an(n);
849
- if (Oe(n))
850
- return cn(n);
872
+ return Te(n);
873
+ if (Ae(n))
874
+ return ct(n);
875
+ if (_e(n))
876
+ return ft(n);
851
877
  }
852
- throw we(n);
878
+ throw Oe(n);
853
879
  }
854
- function sn(n) {
855
- return new b(function(t) {
856
- var e = n[X]();
857
- if (v(e.subscribe))
880
+ function st(n) {
881
+ return new S(function(t) {
882
+ var e = n[z]();
883
+ if (p(e.subscribe))
858
884
  return e.subscribe(t);
859
885
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
860
886
  });
861
887
  }
862
- function on(n) {
863
- return new b(function(t) {
888
+ function ut(n) {
889
+ return new S(function(t) {
864
890
  for (var e = 0; e < n.length && !t.closed; e++)
865
891
  t.next(n[e]);
866
892
  t.complete();
867
893
  });
868
894
  }
869
- function un(n) {
870
- return new b(function(t) {
895
+ function at(n) {
896
+ return new S(function(t) {
871
897
  n.then(function(e) {
872
898
  t.closed || (t.next(e), t.complete());
873
899
  }, function(e) {
874
900
  return t.error(e);
875
- }).then(null, le);
901
+ }).then(null, ye);
876
902
  });
877
903
  }
878
- function an(n) {
879
- return new b(function(t) {
904
+ function ct(n) {
905
+ return new S(function(t) {
880
906
  var e, r;
881
907
  try {
882
- for (var i = P(n), s = i.next(); !s.done; s = i.next()) {
883
- var o = s.value;
884
- if (t.next(o), t.closed)
908
+ for (var i = M(n), o = i.next(); !o.done; o = i.next()) {
909
+ var s = o.value;
910
+ if (t.next(s), t.closed)
885
911
  return;
886
912
  }
887
913
  } catch (c) {
888
914
  e = { error: c };
889
915
  } finally {
890
916
  try {
891
- s && !s.done && (r = i.return) && r.call(i);
917
+ o && !o.done && (r = i.return) && r.call(i);
892
918
  } finally {
893
919
  if (e) throw e.error;
894
920
  }
@@ -896,41 +922,41 @@ function an(n) {
896
922
  t.complete();
897
923
  });
898
924
  }
899
- function xe(n) {
900
- return new b(function(t) {
901
- fn(n, t).catch(function(e) {
925
+ function Te(n) {
926
+ return new S(function(t) {
927
+ lt(n, t).catch(function(e) {
902
928
  return t.error(e);
903
929
  });
904
930
  });
905
931
  }
906
- function cn(n) {
907
- return xe(Ie(n));
932
+ function ft(n) {
933
+ return Te(xe(n));
908
934
  }
909
- function fn(n, t) {
910
- var e, r, i, s;
911
- return je(this, void 0, void 0, function() {
912
- var o, c;
913
- return oe(this, function(u) {
914
- switch (u.label) {
935
+ function lt(n, t) {
936
+ var e, r, i, o;
937
+ return $e(this, void 0, void 0, function() {
938
+ var s, c;
939
+ return ce(this, function(a) {
940
+ switch (a.label) {
915
941
  case 0:
916
- u.trys.push([0, 5, 6, 11]), e = Ue(n), u.label = 1;
942
+ a.trys.push([0, 5, 6, 11]), e = Fe(n), a.label = 1;
917
943
  case 1:
918
944
  return [4, e.next()];
919
945
  case 2:
920
- if (r = u.sent(), !!r.done) return [3, 4];
921
- if (o = r.value, t.next(o), t.closed)
946
+ if (r = a.sent(), !!r.done) return [3, 4];
947
+ if (s = r.value, t.next(s), t.closed)
922
948
  return [2];
923
- u.label = 3;
949
+ a.label = 3;
924
950
  case 3:
925
951
  return [3, 1];
926
952
  case 4:
927
953
  return [3, 11];
928
954
  case 5:
929
- return c = u.sent(), i = { error: c }, [3, 11];
955
+ return c = a.sent(), i = { error: c }, [3, 11];
930
956
  case 6:
931
- return u.trys.push([6, , 9, 10]), r && !r.done && (s = e.return) ? [4, s.call(e)] : [3, 8];
957
+ return a.trys.push([6, , 9, 10]), r && !r.done && (o = e.return) ? [4, o.call(e)] : [3, 8];
932
958
  case 7:
933
- u.sent(), u.label = 8;
959
+ a.sent(), a.label = 8;
934
960
  case 8:
935
961
  return [3, 10];
936
962
  case 9:
@@ -944,78 +970,78 @@ function fn(n, t) {
944
970
  });
945
971
  });
946
972
  }
947
- function M(n, t, e, r, i) {
973
+ function A(n, t, e, r, i) {
948
974
  r === void 0 && (r = 0), i === void 0 && (i = !1);
949
- var s = t.schedule(function() {
975
+ var o = t.schedule(function() {
950
976
  e(), i ? n.add(this.schedule(null, r)) : this.unsubscribe();
951
977
  }, r);
952
- if (n.add(s), !i)
953
- return s;
978
+ if (n.add(o), !i)
979
+ return o;
954
980
  }
955
- function Ae(n, t) {
981
+ function Ce(n, t) {
956
982
  return t === void 0 && (t = 0), T(function(e, r) {
957
- e.subscribe(I(r, function(i) {
958
- return M(r, n, function() {
983
+ e.subscribe(E(r, function(i) {
984
+ return A(r, n, function() {
959
985
  return r.next(i);
960
986
  }, t);
961
987
  }, function() {
962
- return M(r, n, function() {
988
+ return A(r, n, function() {
963
989
  return r.complete();
964
990
  }, t);
965
991
  }, function(i) {
966
- return M(r, n, function() {
992
+ return A(r, n, function() {
967
993
  return r.error(i);
968
994
  }, t);
969
995
  }));
970
996
  });
971
997
  }
972
- function _e(n, t) {
998
+ function Pe(n, t) {
973
999
  return t === void 0 && (t = 0), T(function(e, r) {
974
1000
  r.add(n.schedule(function() {
975
1001
  return e.subscribe(r);
976
1002
  }, t));
977
1003
  });
978
1004
  }
979
- function ln(n, t) {
980
- return x(n).pipe(_e(t), Ae(t));
1005
+ function dt(n, t) {
1006
+ return x(n).pipe(Pe(t), Ce(t));
981
1007
  }
982
- function dn(n, t) {
983
- return x(n).pipe(_e(t), Ae(t));
1008
+ function ht(n, t) {
1009
+ return x(n).pipe(Pe(t), Ce(t));
984
1010
  }
985
- function hn(n, t) {
986
- return new b(function(e) {
1011
+ function yt(n, t) {
1012
+ return new S(function(e) {
987
1013
  var r = 0;
988
1014
  return t.schedule(function() {
989
1015
  r === n.length ? e.complete() : (e.next(n[r++]), e.closed || this.schedule());
990
1016
  });
991
1017
  });
992
1018
  }
993
- function yn(n, t) {
994
- return new b(function(e) {
1019
+ function vt(n, t) {
1020
+ return new S(function(e) {
995
1021
  var r;
996
- return M(e, t, function() {
997
- r = n[Se](), M(e, t, function() {
998
- var i, s, o;
1022
+ return A(e, t, function() {
1023
+ r = n[Ie](), A(e, t, function() {
1024
+ var i, o, s;
999
1025
  try {
1000
- i = r.next(), s = i.value, o = i.done;
1026
+ i = r.next(), o = i.value, s = i.done;
1001
1027
  } catch (c) {
1002
1028
  e.error(c);
1003
1029
  return;
1004
1030
  }
1005
- o ? e.complete() : e.next(s);
1031
+ s ? e.complete() : e.next(o);
1006
1032
  }, 0, !0);
1007
1033
  }), function() {
1008
- return v(r == null ? void 0 : r.return) && r.return();
1034
+ return p(r == null ? void 0 : r.return) && r.return();
1009
1035
  };
1010
1036
  });
1011
1037
  }
1012
1038
  function Me(n, t) {
1013
1039
  if (!n)
1014
1040
  throw new Error("Iterable cannot be null");
1015
- return new b(function(e) {
1016
- M(e, t, function() {
1041
+ return new S(function(e) {
1042
+ A(e, t, function() {
1017
1043
  var r = n[Symbol.asyncIterator]();
1018
- M(e, t, function() {
1044
+ A(e, t, function() {
1019
1045
  r.next().then(function(i) {
1020
1046
  i.done ? e.complete() : e.next(i.value);
1021
1047
  });
@@ -1023,233 +1049,299 @@ function Me(n, t) {
1023
1049
  });
1024
1050
  });
1025
1051
  }
1026
- function vn(n, t) {
1027
- return Me(Ie(n), t);
1052
+ function pt(n, t) {
1053
+ return Me(xe(n), t);
1028
1054
  }
1029
- function pn(n, t) {
1055
+ function bt(n, t) {
1030
1056
  if (n != null) {
1031
- if (me(n))
1032
- return ln(n, t);
1033
- if (pe(n))
1034
- return hn(n, t);
1035
- if (be(n))
1036
- return dn(n, t);
1057
+ if (we(n))
1058
+ return dt(n, t);
1059
+ if (Se(n))
1060
+ return yt(n, t);
1037
1061
  if (ge(n))
1038
- return Me(n, t);
1062
+ return ht(n, t);
1039
1063
  if (Ee(n))
1040
- return yn(n, t);
1041
- if (Oe(n))
1042
- return vn(n, t);
1064
+ return Me(n, t);
1065
+ if (Ae(n))
1066
+ return vt(n, t);
1067
+ if (_e(n))
1068
+ return pt(n, t);
1043
1069
  }
1044
- throw we(n);
1070
+ throw Oe(n);
1045
1071
  }
1046
- function bn(n, t) {
1047
- return t ? pn(n, t) : x(n);
1072
+ function Z(n, t) {
1073
+ return t ? bt(n, t) : x(n);
1048
1074
  }
1049
- function mn() {
1075
+ function mt() {
1050
1076
  for (var n = [], t = 0; t < arguments.length; t++)
1051
1077
  n[t] = arguments[t];
1052
- var e = tn(n);
1053
- return bn(n, e);
1078
+ var e = me(n);
1079
+ return Z(n, e);
1054
1080
  }
1055
- function gn(n) {
1081
+ function St(n) {
1056
1082
  return n instanceof Date && !isNaN(n);
1057
1083
  }
1058
- function Te(n, t) {
1084
+ function F(n, t) {
1059
1085
  return T(function(e, r) {
1060
1086
  var i = 0;
1061
- e.subscribe(I(r, function(s) {
1062
- r.next(n.call(t, s, i++));
1087
+ e.subscribe(E(r, function(o) {
1088
+ r.next(n.call(t, o, i++));
1063
1089
  }));
1064
1090
  });
1065
1091
  }
1066
- function wn(n, t, e, r, i, s, o, c) {
1067
- var u = [], a = 0, l = 0, h = !1, p = function() {
1068
- h && !u.length && !a && t.complete();
1069
- }, f = function(d) {
1070
- return a < r ? y(d) : u.push(d);
1071
- }, y = function(d) {
1072
- a++;
1073
- var m = !1;
1074
- x(e(d, l++)).subscribe(I(t, function(S) {
1075
- t.next(S);
1092
+ var gt = Array.isArray;
1093
+ function wt(n, t) {
1094
+ return gt(t) ? n.apply(void 0, R([], L(t))) : n(t);
1095
+ }
1096
+ function Et(n) {
1097
+ return F(function(t) {
1098
+ return wt(n, t);
1099
+ });
1100
+ }
1101
+ var Ot = Array.isArray, It = Object.getPrototypeOf, At = Object.prototype, xt = Object.keys;
1102
+ function _t(n) {
1103
+ if (n.length === 1) {
1104
+ var t = n[0];
1105
+ if (Ot(t))
1106
+ return { args: t, keys: null };
1107
+ if (Tt(t)) {
1108
+ var e = xt(t);
1109
+ return {
1110
+ args: e.map(function(r) {
1111
+ return t[r];
1112
+ }),
1113
+ keys: e
1114
+ };
1115
+ }
1116
+ }
1117
+ return { args: n, keys: null };
1118
+ }
1119
+ function Tt(n) {
1120
+ return n && typeof n == "object" && It(n) === At;
1121
+ }
1122
+ function Ct(n, t) {
1123
+ return n.reduce(function(e, r, i) {
1124
+ return e[r] = t[i], e;
1125
+ }, {});
1126
+ }
1127
+ function Pt() {
1128
+ for (var n = [], t = 0; t < arguments.length; t++)
1129
+ n[t] = arguments[t];
1130
+ var e = me(n), r = it(n), i = _t(n), o = i.args, s = i.keys;
1131
+ if (o.length === 0)
1132
+ return Z([], e);
1133
+ var c = new S(Mt(o, e, s ? function(a) {
1134
+ return Ct(s, a);
1135
+ } : G));
1136
+ return r ? c.pipe(Et(r)) : c;
1137
+ }
1138
+ function Mt(n, t, e) {
1139
+ return e === void 0 && (e = G), function(r) {
1140
+ se(t, function() {
1141
+ for (var i = n.length, o = new Array(i), s = i, c = i, a = function(f) {
1142
+ se(t, function() {
1143
+ var y = Z(n[f], t), b = !1;
1144
+ y.subscribe(E(r, function(l) {
1145
+ o[f] = l, b || (b = !0, c--), c || r.next(e(o.slice()));
1146
+ }, function() {
1147
+ --s || r.complete();
1148
+ }));
1149
+ }, r);
1150
+ }, u = 0; u < i; u++)
1151
+ a(u);
1152
+ }, r);
1153
+ };
1154
+ }
1155
+ function se(n, t, e) {
1156
+ n ? A(e, n, t) : t();
1157
+ }
1158
+ function Lt(n, t, e, r, i, o, s, c) {
1159
+ var a = [], u = 0, f = 0, y = !1, b = function() {
1160
+ y && !a.length && !u && t.complete();
1161
+ }, l = function(d) {
1162
+ return u < r ? v(d) : a.push(d);
1163
+ }, v = function(d) {
1164
+ u++;
1165
+ var g = !1;
1166
+ x(e(d, f++)).subscribe(E(t, function(w) {
1167
+ t.next(w);
1076
1168
  }, function() {
1077
- m = !0;
1169
+ g = !0;
1078
1170
  }, void 0, function() {
1079
- if (m)
1171
+ if (g)
1080
1172
  try {
1081
- a--;
1082
- for (var S = function() {
1083
- var A = u.shift();
1084
- o || y(A);
1085
- }; u.length && a < r; )
1086
- S();
1087
- p();
1088
- } catch (A) {
1089
- t.error(A);
1173
+ u--;
1174
+ for (var w = function() {
1175
+ var _ = a.shift();
1176
+ s || v(_);
1177
+ }; a.length && u < r; )
1178
+ w();
1179
+ b();
1180
+ } catch (_) {
1181
+ t.error(_);
1090
1182
  }
1091
1183
  }));
1092
1184
  };
1093
- return n.subscribe(I(t, f, function() {
1094
- h = !0, p();
1185
+ return n.subscribe(E(t, l, function() {
1186
+ y = !0, b();
1095
1187
  })), function() {
1096
1188
  };
1097
1189
  }
1098
- function G(n, t, e) {
1099
- return e === void 0 && (e = 1 / 0), v(t) ? G(function(r, i) {
1100
- return Te(function(s, o) {
1101
- return t(r, s, i, o);
1190
+ function $(n, t, e) {
1191
+ return e === void 0 && (e = 1 / 0), p(t) ? $(function(r, i) {
1192
+ return F(function(o, s) {
1193
+ return t(r, o, i, s);
1102
1194
  })(x(n(r, i)));
1103
1195
  }, e) : (typeof t == "number" && (e = t), T(function(r, i) {
1104
- return wn(r, i, n, e);
1196
+ return Lt(r, i, n, e);
1105
1197
  }));
1106
1198
  }
1107
- function Ce(n, t, e) {
1108
- n === void 0 && (n = 0), e === void 0 && (e = Ze);
1199
+ function Le(n, t, e) {
1200
+ n === void 0 && (n = 0), e === void 0 && (e = nt);
1109
1201
  var r = -1;
1110
- return t != null && (ve(t) ? e = t : r = t), new b(function(i) {
1111
- var s = gn(n) ? +n - e.now() : n;
1112
- s < 0 && (s = 0);
1113
- var o = 0;
1202
+ return t != null && (pe(t) ? e = t : r = t), new S(function(i) {
1203
+ var o = St(n) ? +n - e.now() : n;
1204
+ o < 0 && (o = 0);
1205
+ var s = 0;
1114
1206
  return e.schedule(function() {
1115
- i.closed || (i.next(o++), 0 <= r ? this.schedule(void 0, r) : i.complete());
1116
- }, s);
1207
+ i.closed || (i.next(s++), 0 <= r ? this.schedule(void 0, r) : i.complete());
1208
+ }, o);
1117
1209
  });
1118
1210
  }
1119
- function Sn(n, t) {
1120
- return v(t) ? G(n, t, 1) : G(n, 1);
1211
+ function Rt(n, t) {
1212
+ return p(t) ? $(n, t, 1) : $(n, 1);
1121
1213
  }
1122
- function En(n) {
1214
+ function kt(n) {
1123
1215
  return n <= 0 ? function() {
1124
- return en;
1216
+ return rt;
1125
1217
  } : T(function(t, e) {
1126
1218
  var r = 0;
1127
- t.subscribe(I(e, function(i) {
1219
+ t.subscribe(E(e, function(i) {
1128
1220
  ++r <= n && (e.next(i), n <= r && e.complete());
1129
1221
  }));
1130
1222
  });
1131
1223
  }
1132
- function In(n) {
1133
- return Te(function() {
1224
+ function jt(n) {
1225
+ return F(function() {
1134
1226
  return n;
1135
1227
  });
1136
1228
  }
1137
- function On(n, t) {
1138
- return G(function(e, r) {
1139
- return x(n(e, r)).pipe(En(1), In(e));
1229
+ function Dt(n, t) {
1230
+ return $(function(e, r) {
1231
+ return x(n(e, r)).pipe(kt(1), jt(e));
1140
1232
  });
1141
1233
  }
1142
- function xn(n, t) {
1143
- t === void 0 && (t = ye);
1144
- var e = Ce(n, t);
1145
- return On(function() {
1234
+ function Ut(n, t) {
1235
+ t === void 0 && (t = ve);
1236
+ var e = Le(n, t);
1237
+ return Dt(function() {
1146
1238
  return e;
1147
1239
  });
1148
1240
  }
1149
- function ne(n) {
1241
+ function Nt(n) {
1150
1242
  var t;
1151
1243
  t = {
1152
1244
  count: n
1153
1245
  };
1154
- var e = t.count, r = e === void 0 ? 1 / 0 : e, i = t.delay, s = t.resetOnSuccess, o = s === void 0 ? !1 : s;
1155
- return r <= 0 ? de : T(function(c, u) {
1156
- var a = 0, l, h = function() {
1157
- var p = !1;
1158
- l = c.subscribe(I(u, function(f) {
1159
- o && (a = 0), u.next(f);
1160
- }, void 0, function(f) {
1161
- if (a++ < r) {
1162
- var y = function() {
1163
- l ? (l.unsubscribe(), l = null, h()) : p = !0;
1246
+ var e = t.count, r = e === void 0 ? 1 / 0 : e, i = t.delay, o = t.resetOnSuccess, s = o === void 0 ? !1 : o;
1247
+ return r <= 0 ? G : T(function(c, a) {
1248
+ var u = 0, f, y = function() {
1249
+ var b = !1;
1250
+ f = c.subscribe(E(a, function(l) {
1251
+ s && (u = 0), a.next(l);
1252
+ }, void 0, function(l) {
1253
+ if (u++ < r) {
1254
+ var v = function() {
1255
+ f ? (f.unsubscribe(), f = null, y()) : b = !0;
1164
1256
  };
1165
1257
  if (i != null) {
1166
- var d = typeof i == "number" ? Ce(i) : x(i(f, a)), m = I(u, function() {
1167
- m.unsubscribe(), y();
1258
+ var d = typeof i == "number" ? Le(i) : x(i(l, u)), g = E(a, function() {
1259
+ g.unsubscribe(), v();
1168
1260
  }, function() {
1169
- u.complete();
1261
+ a.complete();
1170
1262
  });
1171
- d.subscribe(m);
1263
+ d.subscribe(g);
1172
1264
  } else
1173
- y();
1265
+ v();
1174
1266
  } else
1175
- u.error(f);
1176
- })), p && (l.unsubscribe(), l = null, h());
1267
+ a.error(l);
1268
+ })), b && (f.unsubscribe(), f = null, y());
1177
1269
  };
1178
- h();
1270
+ y();
1179
1271
  });
1180
1272
  }
1181
- function te(n) {
1273
+ function $t(n) {
1182
1274
  return T(function(t, e) {
1183
- x(n).subscribe(I(e, function() {
1275
+ x(n).subscribe(E(e, function() {
1184
1276
  return e.complete();
1185
- }, Y)), !e.closed && t.subscribe(e);
1277
+ }, q)), !e.closed && t.subscribe(e);
1186
1278
  });
1187
1279
  }
1188
- async function An(n, t) {
1280
+ async function Gt(n, t) {
1189
1281
  const e = n.getReader();
1190
1282
  let r;
1191
1283
  for (; !(r = await e.read()).done; )
1192
1284
  t(r.value);
1193
1285
  }
1194
- function _n(n) {
1286
+ function Ft(n) {
1195
1287
  let t, e, r, i = !1;
1196
- return function(o) {
1197
- t === void 0 ? (t = o, e = 0, r = -1) : t = Tn(t, o);
1288
+ return function(s) {
1289
+ t === void 0 ? (t = s, e = 0, r = -1) : t = Vt(t, s);
1198
1290
  const c = t.length;
1199
- let u = 0;
1291
+ let a = 0;
1200
1292
  for (; e < c; ) {
1201
- i && (t[e] === 10 && (u = ++e), i = !1);
1202
- let a = -1;
1203
- for (; e < c && a === -1; ++e)
1293
+ i && (t[e] === 10 && (a = ++e), i = !1);
1294
+ let u = -1;
1295
+ for (; e < c && u === -1; ++e)
1204
1296
  switch (t[e]) {
1205
1297
  case 58:
1206
- r === -1 && (r = e - u);
1298
+ r === -1 && (r = e - a);
1207
1299
  break;
1208
1300
  case 13:
1209
1301
  i = !0;
1210
1302
  case 10:
1211
- a = e;
1303
+ u = e;
1212
1304
  break;
1213
1305
  }
1214
- if (a === -1)
1306
+ if (u === -1)
1215
1307
  break;
1216
- n(t.subarray(u, a), r), u = e, r = -1;
1308
+ n(t.subarray(a, u), r), a = e, r = -1;
1217
1309
  }
1218
- u === c ? t = void 0 : u !== 0 && (t = t.subarray(u), e -= u);
1310
+ a === c ? t = void 0 : a !== 0 && (t = t.subarray(a), e -= a);
1219
1311
  };
1220
1312
  }
1221
- function Mn(n, t, e) {
1222
- let r = re();
1313
+ function Ht(n, t, e) {
1314
+ let r = ue();
1223
1315
  const i = new TextDecoder();
1224
- return function(o, c) {
1225
- if (o.length === 0)
1226
- e == null || e(r), r = re();
1316
+ return function(s, c) {
1317
+ if (s.length === 0)
1318
+ e == null || e(r), r = ue();
1227
1319
  else if (c > 0) {
1228
- const u = i.decode(o.subarray(0, c)), a = c + (o[c + 1] === 32 ? 2 : 1), l = i.decode(o.subarray(a));
1229
- switch (u) {
1320
+ const a = i.decode(s.subarray(0, c)), u = c + (s[c + 1] === 32 ? 2 : 1), f = i.decode(s.subarray(u));
1321
+ switch (a) {
1230
1322
  case "data":
1231
1323
  r.data = r.data ? r.data + `
1232
- ` + l : l;
1324
+ ` + f : f;
1233
1325
  break;
1234
1326
  case "event":
1235
- r.event = l;
1327
+ r.event = f;
1236
1328
  break;
1237
1329
  case "id":
1238
- n(r.id = l);
1330
+ n(r.id = f);
1239
1331
  break;
1240
1332
  case "retry":
1241
- const h = parseInt(l, 10);
1242
- isNaN(h) || t(r.retry = h);
1333
+ const y = parseInt(f, 10);
1334
+ isNaN(y) || t(r.retry = y);
1243
1335
  break;
1244
1336
  }
1245
1337
  }
1246
1338
  };
1247
1339
  }
1248
- function Tn(n, t) {
1340
+ function Vt(n, t) {
1249
1341
  const e = new Uint8Array(n.length + t.length);
1250
1342
  return e.set(n), e.set(t, n.length), e;
1251
1343
  }
1252
- function re() {
1344
+ function ue() {
1253
1345
  return {
1254
1346
  data: "",
1255
1347
  event: "",
@@ -1257,7 +1349,7 @@ function re() {
1257
1349
  retry: void 0
1258
1350
  };
1259
1351
  }
1260
- var Cn = function(n, t) {
1352
+ var Bt = function(n, t) {
1261
1353
  var e = {};
1262
1354
  for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
1263
1355
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
@@ -1265,272 +1357,379 @@ var Cn = function(n, t) {
1265
1357
  t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (e[r[i]] = n[r[i]]);
1266
1358
  return e;
1267
1359
  };
1268
- const B = "text/event-stream", Pn = 1e3, ie = "last-event-id";
1269
- function Dn(n, t) {
1270
- var { signal: e, headers: r, onopen: i, onmessage: s, onclose: o, onerror: c, openWhenHidden: u, fetch: a } = t, l = Cn(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1271
- return new Promise((h, p) => {
1272
- const f = Object.assign({}, r);
1273
- f.accept || (f.accept = B);
1274
- let y;
1360
+ const J = "text/event-stream", Kt = 1e3, ae = "last-event-id";
1361
+ function Yt(n, t) {
1362
+ var { signal: e, headers: r, onopen: i, onmessage: o, onclose: s, onerror: c, openWhenHidden: a, fetch: u } = t, f = Bt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1363
+ return new Promise((y, b) => {
1364
+ const l = Object.assign({}, r);
1365
+ l.accept || (l.accept = J);
1366
+ let v;
1275
1367
  function d() {
1276
- y.abort(), document.hidden || F();
1368
+ v.abort(), document.hidden || H();
1277
1369
  }
1278
- u || document.addEventListener("visibilitychange", d);
1279
- let m = Pn, S = 0;
1280
- function A() {
1281
- document.removeEventListener("visibilitychange", d), window.clearTimeout(S), y.abort();
1370
+ a || document.addEventListener("visibilitychange", d);
1371
+ let g = Kt, w = 0;
1372
+ function _() {
1373
+ document.removeEventListener("visibilitychange", d), window.clearTimeout(w), v.abort();
1282
1374
  }
1283
1375
  e == null || e.addEventListener("abort", () => {
1284
- A(), h();
1376
+ _(), y();
1285
1377
  });
1286
- const Pe = a ?? window.fetch, De = i ?? kn;
1287
- async function F() {
1288
- var K;
1289
- y = new AbortController();
1378
+ const ke = u ?? window.fetch, je = i ?? qt;
1379
+ async function H() {
1380
+ var V;
1381
+ v = new AbortController();
1290
1382
  try {
1291
- const k = await Pe(n, Object.assign(Object.assign({}, l), { headers: f, signal: y.signal }));
1292
- await De(k), await An(k.body, _n(Mn((E) => {
1293
- E ? f[ie] = E : delete f[ie];
1294
- }, (E) => {
1295
- m = E;
1296
- }, s))), o == null || o(), A(), h();
1297
- } catch (k) {
1298
- if (!y.signal.aborted)
1383
+ const j = await ke(n, Object.assign(Object.assign({}, f), { headers: l, signal: v.signal }));
1384
+ await je(j), await Gt(j.body, Ft(Ht((I) => {
1385
+ I ? l[ae] = I : delete l[ae];
1386
+ }, (I) => {
1387
+ g = I;
1388
+ }, o))), s == null || s(), _(), y();
1389
+ } catch (j) {
1390
+ if (!v.signal.aborted)
1299
1391
  try {
1300
- const E = (K = c == null ? void 0 : c(k)) !== null && K !== void 0 ? K : m;
1301
- window.clearTimeout(S), S = window.setTimeout(F, E);
1302
- } catch (E) {
1303
- A(), p(E);
1392
+ const I = (V = c == null ? void 0 : c(j)) !== null && V !== void 0 ? V : g;
1393
+ window.clearTimeout(w), w = window.setTimeout(H, I);
1394
+ } catch (I) {
1395
+ _(), b(I);
1304
1396
  }
1305
1397
  }
1306
1398
  }
1307
- F();
1399
+ H();
1308
1400
  });
1309
1401
  }
1310
- function kn(n) {
1402
+ function qt(n) {
1311
1403
  const t = n.headers.get("content-type");
1312
- if (!(t != null && t.startsWith(B)))
1313
- throw new Error(`Expected content-type to be ${B}, Actual: ${t}`);
1314
- }
1315
- function se(n) {
1316
- const { endpoint: t, apiKey: e, payload: r } = n;
1317
- return new b((i) => {
1318
- const s = new AbortController();
1319
- return Dn(t, {
1404
+ if (!(t != null && t.startsWith(J)))
1405
+ throw new Error(`Expected content-type to be ${J}, Actual: ${t}`);
1406
+ }
1407
+ function Wt(n) {
1408
+ const { endpoint: t, apiKey: e, payload: r, debugMode: i } = n;
1409
+ return new S((o) => {
1410
+ const s = new AbortController(), c = {
1411
+ "Content-Type": "application/json"
1412
+ };
1413
+ e && (c["X-API-KEY"] = e);
1414
+ const a = new URLSearchParams();
1415
+ i && a.set("is_debug", "true");
1416
+ const u = new URL(t);
1417
+ return a.toString() && (u.search = a.toString()), Yt(u.toString(), {
1320
1418
  method: "POST",
1321
- headers: {
1322
- "X-API-KEY": e,
1323
- "Content-Type": "application/json"
1324
- },
1419
+ headers: c,
1325
1420
  body: r ? JSON.stringify(r) : void 0,
1326
1421
  signal: s.signal,
1327
- onopen: async (o) => {
1328
- o.ok || (i.error(o), s.abort());
1422
+ /**
1423
+ * Allow SSE to work when the page is hidden.
1424
+ * https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
1425
+ */
1426
+ openWhenHidden: !0,
1427
+ onopen: async (f) => {
1428
+ f.ok || (o.error(f), s.abort());
1329
1429
  },
1330
- onmessage: (o) => {
1331
- i.next(JSON.parse(o.data));
1430
+ onmessage: (f) => {
1431
+ o.next(JSON.parse(f.data));
1332
1432
  },
1333
1433
  onclose: () => {
1334
- i.complete();
1434
+ o.complete();
1335
1435
  },
1336
- onerror: (o) => {
1337
- throw i.error(o), s.abort(), o;
1436
+ onerror: (f) => {
1437
+ throw o.error(f), s.abort(), f;
1338
1438
  }
1339
1439
  }), () => {
1340
1440
  s.abort();
1341
1441
  };
1342
1442
  });
1343
1443
  }
1344
- class Nn {
1345
- constructor(t) {
1346
- _(this, "isConnecting", !1);
1347
- _(this, "apiKey");
1348
- _(this, "endpoint");
1349
- _(this, "destroy$", new he());
1350
- if (!t.apiKey)
1351
- throw new Error("apiKey must be required");
1352
- if (!t.endpoint)
1353
- throw new Error("botProviderName must be required");
1354
- this.apiKey = t.apiKey, this.endpoint = t.endpoint;
1444
+ class Jt {
1445
+ constructor() {
1446
+ m(this, "listeners", {});
1355
1447
  }
1356
- setChannel(t, e) {
1357
- var r;
1358
- (r = e == null ? void 0 : e.onSseStart) == null || r.call(e), this.isConnecting = !0, se({
1359
- apiKey: this.apiKey,
1360
- endpoint: this.endpoint,
1361
- payload: {
1362
- action: $.RESET_CHANNEL,
1363
- customChannelId: t.customChannelId,
1364
- customMessageId: t == null ? void 0 : t.customMessageId,
1365
- text: ""
1366
- }
1367
- }).pipe(te(this.destroy$), ne(3)).subscribe({
1368
- next: (i) => {
1369
- var s;
1370
- (s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, i);
1371
- },
1372
- error: (i) => {
1373
- var s;
1374
- (s = e == null ? void 0 : e.onSseError) == null || s.call(e, i), this.isConnecting = !1;
1375
- },
1376
- complete: () => {
1377
- var i;
1378
- (i = e == null ? void 0 : e.onSseCompleted) == null || i.call(e), this.isConnecting = !1;
1379
- }
1448
+ on(t, e) {
1449
+ this.listeners = Object.assign({}, this.listeners, {
1450
+ [t]: (this.listeners[t] ?? []).concat(e)
1380
1451
  });
1381
1452
  }
1382
- sendMessage(t, e) {
1383
- var r;
1384
- this.isConnecting = !0, (r = e == null ? void 0 : e.onSseStart) == null || r.call(e), se({
1453
+ off(t, e) {
1454
+ this.listeners[t] && (this.listeners = Object.assign({}, this.listeners, {
1455
+ [t]: (this.listeners[t] ?? []).filter((r) => r !== e)
1456
+ }));
1457
+ }
1458
+ remove(t) {
1459
+ delete this.listeners[t];
1460
+ }
1461
+ emit(t, ...e) {
1462
+ this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
1463
+ }
1464
+ }
1465
+ class zt {
1466
+ constructor(t) {
1467
+ m(this, "apiKey");
1468
+ m(this, "endpoint");
1469
+ m(this, "debugMode");
1470
+ m(this, "destroy$", new Q());
1471
+ m(this, "sseEmitter", new Jt());
1472
+ m(this, "transformSsePayload");
1473
+ if (!t.endpoint && !t.botProviderEndpoint)
1474
+ throw new Error("Either endpoint or botProviderEndpoint must be provided");
1475
+ if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, !t.endpoint && t.botProviderEndpoint) {
1476
+ const e = t.botProviderEndpoint.replace(/\/+$/, "");
1477
+ this.endpoint = `${e}/message/sse`;
1478
+ } else t.endpoint && (this.endpoint = t.endpoint, this.debugMode && console.warn(
1479
+ '[AsgardServiceClient] The "endpoint" option is deprecated and will be removed in the next major version. Please use "botProviderEndpoint" instead. The SSE endpoint will be automatically derived as "${botProviderEndpoint}/message/sse".'
1480
+ ));
1481
+ }
1482
+ on(t, e) {
1483
+ this.sseEmitter.remove(t), this.sseEmitter.on(t, e);
1484
+ }
1485
+ handleEvent(t) {
1486
+ switch (t.eventType) {
1487
+ case h.INIT:
1488
+ this.sseEmitter.emit(
1489
+ h.INIT,
1490
+ t
1491
+ );
1492
+ break;
1493
+ case h.PROCESS_START:
1494
+ case h.PROCESS_COMPLETE:
1495
+ this.sseEmitter.emit(
1496
+ h.PROCESS,
1497
+ t
1498
+ );
1499
+ break;
1500
+ case h.MESSAGE_START:
1501
+ case h.MESSAGE_DELTA:
1502
+ case h.MESSAGE_COMPLETE:
1503
+ this.sseEmitter.emit(
1504
+ h.MESSAGE,
1505
+ t
1506
+ );
1507
+ break;
1508
+ case h.TOOL_CALL_START:
1509
+ case h.TOOL_CALL_COMPLETE:
1510
+ this.sseEmitter.emit(
1511
+ h.TOOL_CALL,
1512
+ t
1513
+ );
1514
+ break;
1515
+ case h.DONE:
1516
+ this.sseEmitter.emit(
1517
+ h.DONE,
1518
+ t
1519
+ );
1520
+ break;
1521
+ case h.ERROR:
1522
+ this.sseEmitter.emit(
1523
+ h.ERROR,
1524
+ t
1525
+ );
1526
+ break;
1527
+ }
1528
+ }
1529
+ fetchSse(t, e) {
1530
+ var r, i;
1531
+ (r = e == null ? void 0 : e.onSseStart) == null || r.call(e), Wt({
1385
1532
  apiKey: this.apiKey,
1386
1533
  endpoint: this.endpoint,
1387
- payload: {
1388
- action: $.NONE,
1389
- customChannelId: t.customChannelId,
1390
- customMessageId: t == null ? void 0 : t.customMessageId,
1391
- text: t.text
1392
- }
1534
+ debugMode: this.debugMode,
1535
+ payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t
1393
1536
  }).pipe(
1394
- Sn((i) => mn(i).pipe(xn((e == null ? void 0 : e.delayTime) ?? 50))),
1395
- te(this.destroy$),
1396
- ne(3)
1537
+ Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
1538
+ $t(this.destroy$),
1539
+ Nt(3)
1397
1540
  ).subscribe({
1398
- next: (i) => {
1541
+ next: (o) => {
1399
1542
  var s;
1400
- (s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, i);
1543
+ (s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, o), this.handleEvent(o);
1401
1544
  },
1402
- error: (i) => {
1545
+ error: (o) => {
1403
1546
  var s;
1404
- (s = e == null ? void 0 : e.onSseError) == null || s.call(e, i), this.isConnecting = !1;
1547
+ (s = e == null ? void 0 : e.onSseError) == null || s.call(e, o);
1405
1548
  },
1406
1549
  complete: () => {
1407
- var i;
1408
- (i = e == null ? void 0 : e.onSseCompleted) == null || i.call(e), this.isConnecting = !1;
1550
+ var o;
1551
+ (o = e == null ? void 0 : e.onSseCompleted) == null || o.call(e);
1409
1552
  }
1410
1553
  });
1411
1554
  }
1412
1555
  close() {
1413
- this.isConnecting = !1, this.destroy$.next(), this.destroy$.complete();
1556
+ this.destroy$.next(), this.destroy$.complete();
1414
1557
  }
1415
1558
  }
1416
- class w {
1417
- constructor({ messages: t, typingMessages: e }) {
1418
- _(this, "messages");
1419
- _(this, "typingMessages", null);
1420
- this.messages = t, this.typingMessages = e;
1559
+ class Re {
1560
+ constructor(t) {
1561
+ m(this, "client");
1562
+ m(this, "customChannelId");
1563
+ m(this, "customMessageId");
1564
+ m(this, "isConnecting$");
1565
+ m(this, "conversation$");
1566
+ m(this, "statesObserver");
1567
+ m(this, "statesSubscription");
1568
+ if (!t.client)
1569
+ throw new Error("client must be required");
1570
+ if (!t.customChannelId)
1571
+ throw new Error("customChannelId must be required");
1572
+ this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new re(!1), this.conversation$ = new re(t.conversation), this.statesObserver = t.statesObserver;
1421
1573
  }
1422
- resetConversation() {
1423
- return new w({
1424
- messages: null,
1425
- typingMessages: null
1426
- });
1574
+ static async reset(t, e, r) {
1575
+ const i = new Re(t);
1576
+ try {
1577
+ return i.subscribe(), await i.resetChannel(e, r), i;
1578
+ } catch (o) {
1579
+ throw i.close(), o;
1580
+ }
1427
1581
  }
1428
- pushMessage(t, e) {
1429
- const r = new Map(t.messages);
1430
- return r.set(e.messageId, e), new w({
1431
- messages: r,
1432
- typingMessages: t.typingMessages
1582
+ subscribe() {
1583
+ this.statesSubscription = Pt([
1584
+ this.isConnecting$,
1585
+ this.conversation$
1586
+ ]).pipe(
1587
+ F(([t, e]) => ({
1588
+ isConnecting: t,
1589
+ conversation: e
1590
+ }))
1591
+ ).subscribe(this.statesObserver);
1592
+ }
1593
+ fetchSse(t, e) {
1594
+ return new Promise((r, i) => {
1595
+ this.isConnecting$.next(!0), this.client.fetchSse(t, {
1596
+ onSseStart: e == null ? void 0 : e.onSseStart,
1597
+ onSseMessage: (o) => {
1598
+ var s;
1599
+ (s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, o), this.conversation$.next(this.conversation$.value.onMessage(o));
1600
+ },
1601
+ onSseError: (o) => {
1602
+ var s;
1603
+ (s = e == null ? void 0 : e.onSseError) == null || s.call(e, o), this.isConnecting$.next(!1), i(o);
1604
+ },
1605
+ onSseCompleted: () => {
1606
+ var o;
1607
+ (o = e == null ? void 0 : e.onSseCompleted) == null || o.call(e), this.isConnecting$.next(!1), r();
1608
+ }
1609
+ });
1433
1610
  });
1434
1611
  }
1435
- onMessage(t, e, r) {
1436
- const i = (r == null ? void 0 : r.showDebugMessage) ?? !1;
1437
- switch (e.eventType) {
1438
- case g.MESSAGE_START:
1439
- return t.onMessageStart(
1440
- t,
1441
- e,
1442
- { showDebugMessage: i }
1612
+ resetChannel(t, e) {
1613
+ return this.fetchSse(
1614
+ {
1615
+ action: K.RESET_CHANNEL,
1616
+ customChannelId: this.customChannelId,
1617
+ customMessageId: this.customMessageId,
1618
+ text: (t == null ? void 0 : t.text) || "",
1619
+ payload: t == null ? void 0 : t.payload
1620
+ },
1621
+ e
1622
+ );
1623
+ }
1624
+ sendMessage(t, e) {
1625
+ const r = t.text.trim(), i = t.customMessageId ?? crypto.randomUUID();
1626
+ return this.conversation$.next(
1627
+ this.conversation$.value.pushMessage({
1628
+ type: "user",
1629
+ messageId: i,
1630
+ text: r,
1631
+ time: /* @__PURE__ */ new Date()
1632
+ })
1633
+ ), this.fetchSse(
1634
+ {
1635
+ action: K.NONE,
1636
+ customChannelId: this.customChannelId,
1637
+ customMessageId: i,
1638
+ payload: t == null ? void 0 : t.payload,
1639
+ text: r
1640
+ },
1641
+ e
1642
+ );
1643
+ }
1644
+ close() {
1645
+ var t;
1646
+ this.isConnecting$.complete(), this.conversation$.complete(), (t = this.statesSubscription) == null || t.unsubscribe();
1647
+ }
1648
+ }
1649
+ class C {
1650
+ constructor({ messages: t }) {
1651
+ m(this, "messages", null);
1652
+ this.messages = t;
1653
+ }
1654
+ pushMessage(t) {
1655
+ const e = new Map(this.messages);
1656
+ return e.set(t.messageId, t), new C({ messages: e });
1657
+ }
1658
+ onMessage(t) {
1659
+ switch (t.eventType) {
1660
+ case h.MESSAGE_START:
1661
+ return this.onMessageStart(
1662
+ t
1443
1663
  );
1444
- case g.MESSAGE_DELTA:
1445
- return t.onMessageDelta(
1446
- t,
1447
- e,
1448
- { showDebugMessage: i }
1664
+ case h.MESSAGE_DELTA:
1665
+ return this.onMessageDelta(
1666
+ t
1449
1667
  );
1450
- case g.MESSAGE_COMPLETE:
1451
- return t.onMessageComplete(
1452
- t,
1453
- e,
1454
- { showDebugMessage: i }
1668
+ case h.MESSAGE_COMPLETE:
1669
+ return this.onMessageComplete(
1670
+ t
1455
1671
  );
1456
- case g.DONE:
1457
- return t.onMessageDone(t);
1672
+ case h.ERROR:
1673
+ return this.onMessageError(t);
1458
1674
  default:
1459
- return t;
1675
+ return this;
1460
1676
  }
1461
1677
  }
1462
- onMessageStart(t, e, r) {
1463
- const i = e.fact.messageStart.message, s = new Map(t.typingMessages);
1464
- return i.isDebug && !r.showDebugMessage || s != null && s.has(i.messageId) ? new w({
1465
- messages: t.messages,
1466
- typingMessages: s
1467
- }) : (s.set(i.messageId, {
1678
+ onMessageStart(t) {
1679
+ const e = t.fact.messageStart.message, r = new Map(this.messages);
1680
+ return r.set(e.messageId, {
1468
1681
  type: "bot",
1469
- eventType: g.MESSAGE_START,
1682
+ eventType: h.MESSAGE_START,
1470
1683
  isTyping: !0,
1471
1684
  typingText: "",
1472
- messageId: i.messageId,
1473
- message: i,
1685
+ messageId: e.messageId,
1686
+ message: e,
1474
1687
  time: /* @__PURE__ */ new Date()
1475
- }), new w({
1476
- messages: t.messages,
1477
- typingMessages: s
1478
- }));
1688
+ }), new C({ messages: r });
1479
1689
  }
1480
- onMessageDelta(t, e, r) {
1481
- const i = e.fact.messageDelta.message, s = new Map(t.messages), o = new Map(t.typingMessages), c = o.get(i.messageId);
1482
- if (i.isDebug && !r.showDebugMessage || s.has(i.messageId) || (c == null ? void 0 : c.eventType) === g.MESSAGE_COMPLETE)
1483
- return new w({
1484
- messages: t.messages,
1485
- typingMessages: o
1486
- });
1487
- const u = `${(c == null ? void 0 : c.typingText) ?? ""}${i.text}`;
1488
- return o.set(i.messageId, {
1690
+ onMessageDelta(t) {
1691
+ const e = t.fact.messageDelta.message, r = new Map(this.messages), i = r.get(e.messageId);
1692
+ if ((i == null ? void 0 : i.type) !== "bot") return this;
1693
+ const o = `${(i == null ? void 0 : i.typingText) ?? ""}${e.text}`;
1694
+ return r.set(e.messageId, {
1489
1695
  type: "bot",
1490
- eventType: g.MESSAGE_DELTA,
1696
+ eventType: h.MESSAGE_DELTA,
1491
1697
  isTyping: !0,
1492
- typingText: u,
1493
- messageId: i.messageId,
1494
- message: i,
1698
+ typingText: o,
1699
+ messageId: e.messageId,
1700
+ message: e,
1495
1701
  time: /* @__PURE__ */ new Date()
1496
- }), new w({
1497
- messages: t.messages,
1498
- typingMessages: o
1499
- });
1702
+ }), new C({ messages: r });
1500
1703
  }
1501
- onMessageComplete(t, e, r) {
1502
- const i = e.fact.messageComplete.message, s = new Map(t.messages), o = new Map(t.typingMessages);
1503
- return i.isDebug && !r.showDebugMessage ? new w({
1504
- messages: s,
1505
- typingMessages: o
1506
- }) : (s.set(i.messageId, {
1704
+ onMessageComplete(t) {
1705
+ const e = t.fact.messageComplete.message, r = new Map(this.messages);
1706
+ return r.set(e.messageId, {
1507
1707
  type: "bot",
1508
- eventType: g.MESSAGE_COMPLETE,
1708
+ eventType: h.MESSAGE_COMPLETE,
1509
1709
  isTyping: !1,
1510
1710
  typingText: null,
1511
- messageId: i.messageId,
1512
- message: i,
1711
+ messageId: e.messageId,
1712
+ message: e,
1513
1713
  time: /* @__PURE__ */ new Date()
1514
- }), o.delete(i.messageId), new w({
1515
- messages: s,
1516
- typingMessages: o
1517
- }));
1714
+ }), new C({ messages: r });
1518
1715
  }
1519
- onMessageDone(t) {
1520
- const e = new Map(t.messages), r = new Map(t.typingMessages);
1521
- return r.forEach((i, s) => {
1522
- i.eventType === g.MESSAGE_COMPLETE && (e.set(i.messageId, i), r.delete(s));
1523
- }), new w({
1524
- messages: t.messages,
1525
- typingMessages: r
1526
- });
1716
+ onMessageError(t) {
1717
+ const e = crypto.randomUUID(), r = t.fact.runError.error, i = new Map(this.messages);
1718
+ return i.set(e, {
1719
+ type: "error",
1720
+ eventType: h.ERROR,
1721
+ messageId: e,
1722
+ error: r,
1723
+ time: /* @__PURE__ */ new Date()
1724
+ }), new C({ messages: i });
1527
1725
  }
1528
1726
  }
1529
1727
  export {
1530
- Nn as AsgardServiceClient,
1531
- w as Conversation,
1532
- g as EventType,
1533
- $ as FetchSseAction,
1728
+ zt as AsgardServiceClient,
1729
+ Re as Channel,
1730
+ C as Conversation,
1731
+ h as EventType,
1732
+ K as FetchSseAction,
1534
1733
  Ne as MessageTemplateType
1535
1734
  };
1536
1735
  //# sourceMappingURL=index.mjs.map