@asgard-js/core 0.3.24 → 0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,31 +1,169 @@
1
- class I extends Error {
1
+ class w extends Error {
2
2
  status;
3
3
  statusText;
4
+ /**
5
+ * The decoded error payload, when the response carried one.
6
+ *
7
+ * Consumers branch on this — `asgard-ai-data-insight-web` reads `reason_code` off it to raise its
8
+ * credit-limit dialog on a `429` — so **always pass it when constructing from a real response**,
9
+ * even though the parameter is optional.
10
+ */
4
11
  body;
12
+ // `body` is optional because every construction site derives it from a response whose text or JSON
13
+ // may fail to parse, yielding `undefined` or `null`. An absent body is therefore a normal outcome
14
+ // rather than a caller mistake, and a test raising a status-only error need not pass a filler value.
5
15
  constructor(t, e, r) {
6
16
  super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = r;
7
17
  }
8
18
  }
9
19
  function Tn(n) {
10
- return n instanceof I;
20
+ return n instanceof w;
21
+ }
22
+ var $ = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))($ || {}), d = /* @__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.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Ke = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ke || {}), qe = /* @__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.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(qe || {});
23
+ async function Ye(n, t) {
24
+ const e = n.getReader();
25
+ let r;
26
+ for (; !(r = await e.read()).done; )
27
+ t(r.value);
28
+ }
29
+ function Xe(n) {
30
+ let t, e, r, s = !1;
31
+ return function(i) {
32
+ t === void 0 ? (t = i, e = 0, r = -1) : t = We(t, i);
33
+ const a = t.length;
34
+ let c = 0;
35
+ for (; e < a; ) {
36
+ s && (t[e] === 10 && (c = ++e), s = !1);
37
+ let u = -1;
38
+ for (; e < a && u === -1; ++e)
39
+ switch (t[e]) {
40
+ case 58:
41
+ r === -1 && (r = e - c);
42
+ break;
43
+ case 13:
44
+ s = !0;
45
+ case 10:
46
+ u = e;
47
+ break;
48
+ }
49
+ if (u === -1)
50
+ break;
51
+ n(t.subarray(c, u), r), c = e, r = -1;
52
+ }
53
+ c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
54
+ };
55
+ }
56
+ function Ve(n, t, e) {
57
+ let r = ie();
58
+ const s = new TextDecoder();
59
+ return function(i, a) {
60
+ if (i.length === 0)
61
+ e?.(r), r = ie();
62
+ else if (a > 0) {
63
+ const c = s.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(u));
64
+ switch (c) {
65
+ case "data":
66
+ r.data = r.data ? r.data + `
67
+ ` + h : h;
68
+ break;
69
+ case "event":
70
+ r.event = h;
71
+ break;
72
+ case "id":
73
+ n(r.id = h);
74
+ break;
75
+ case "retry":
76
+ const m = parseInt(h, 10);
77
+ isNaN(m) || t(r.retry = m);
78
+ break;
79
+ }
80
+ }
81
+ };
82
+ }
83
+ function We(n, t) {
84
+ const e = new Uint8Array(n.length + t.length);
85
+ return e.set(n), e.set(t, n.length), e;
86
+ }
87
+ function ie() {
88
+ return {
89
+ data: "",
90
+ event: "",
91
+ id: "",
92
+ retry: void 0
93
+ };
94
+ }
95
+ var ze = function(n, t) {
96
+ var e = {};
97
+ for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
98
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
99
+ for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
100
+ t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
101
+ return e;
102
+ };
103
+ const Q = "text/event-stream", Je = 1e3, ae = "last-event-id";
104
+ function ve(n, t) {
105
+ var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = ze(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
106
+ return new Promise((m, b) => {
107
+ const l = Object.assign({}, r);
108
+ l.accept || (l.accept = Q);
109
+ let f;
110
+ function p() {
111
+ f.abort(), document.hidden || V();
112
+ }
113
+ c || document.addEventListener("visibilitychange", p);
114
+ let L = Je, E = 0;
115
+ function _() {
116
+ document.removeEventListener("visibilitychange", p), window.clearTimeout(E), f.abort();
117
+ }
118
+ e?.addEventListener("abort", () => {
119
+ _(), m();
120
+ });
121
+ const Ge = u ?? window.fetch, Be = s ?? Qe;
122
+ async function V() {
123
+ var W;
124
+ f = new AbortController();
125
+ try {
126
+ const F = await Ge(n, Object.assign(Object.assign({}, h), { headers: l, signal: f.signal }));
127
+ await Be(F), await Ye(F.body, Xe(Ve((x) => {
128
+ x ? l[ae] = x : delete l[ae];
129
+ }, (x) => {
130
+ L = x;
131
+ }, o))), i?.(), _(), m();
132
+ } catch (F) {
133
+ if (!f.signal.aborted)
134
+ try {
135
+ const x = (W = a?.(F)) !== null && W !== void 0 ? W : L;
136
+ window.clearTimeout(E), E = window.setTimeout(V, x);
137
+ } catch (x) {
138
+ _(), b(x);
139
+ }
140
+ }
141
+ }
142
+ V();
143
+ });
11
144
  }
12
- var $ = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))($ || {}), d = /* @__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.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Be = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Be || {}), Ke = /* @__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.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(Ke || {}), Q = function(n, t) {
13
- return Q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
145
+ function Qe(n) {
146
+ const t = n.headers.get("content-type");
147
+ if (!t?.startsWith(Q))
148
+ throw new Error(`Expected content-type to be ${Q}, Actual: ${t}`);
149
+ }
150
+ var Z = function(n, t) {
151
+ return Z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
14
152
  e.__proto__ = r;
15
153
  } || function(e, r) {
16
154
  for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
17
- }, Q(n, t);
155
+ }, Z(n, t);
18
156
  };
19
157
  function T(n, t) {
20
158
  if (typeof t != "function" && t !== null)
21
159
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
22
- Q(n, t);
160
+ Z(n, t);
23
161
  function e() {
24
162
  this.constructor = n;
25
163
  }
26
164
  n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
27
165
  }
28
- function qe(n, t, e, r) {
166
+ function Ze(n, t, e, r) {
29
167
  function s(o) {
30
168
  return o instanceof e ? o : new e(function(i) {
31
169
  i(o);
@@ -52,7 +190,7 @@ function qe(n, t, e, r) {
52
190
  u((r = r.apply(n, t || [])).next());
53
191
  });
54
192
  }
55
- function ve(n, t) {
193
+ function ye(n, t) {
56
194
  var e = { label: 0, sent: function() {
57
195
  if (o[0] & 1) throw o[1];
58
196
  return o[1];
@@ -144,10 +282,10 @@ function H(n, t, e) {
144
282
  (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
145
283
  return n.concat(o || Array.prototype.slice.call(t));
146
284
  }
147
- function U(n) {
148
- return this instanceof U ? (this.v = n, this) : new U(n);
285
+ function M(n) {
286
+ return this instanceof M ? (this.v = n, this) : new M(n);
149
287
  }
150
- function Ye(n, t, e) {
288
+ function et(n, t, e) {
151
289
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
152
290
  var r = e.apply(n, t || []), s, o = [];
153
291
  return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), s[Symbol.asyncIterator] = function() {
@@ -160,8 +298,8 @@ function Ye(n, t, e) {
160
298
  }
161
299
  function a(l, f) {
162
300
  r[l] && (s[l] = function(p) {
163
- return new Promise(function(L, w) {
164
- o.push([l, p, L, w]) > 1 || c(l, p);
301
+ return new Promise(function(L, E) {
302
+ o.push([l, p, L, E]) > 1 || c(l, p);
165
303
  });
166
304
  }, f && (s[l] = f(s[l])));
167
305
  }
@@ -173,7 +311,7 @@ function Ye(n, t, e) {
173
311
  }
174
312
  }
175
313
  function u(l) {
176
- l.value instanceof U ? Promise.resolve(l.value.v).then(h, m) : b(o[0][2], l);
314
+ l.value instanceof M ? Promise.resolve(l.value.v).then(h, m) : b(o[0][2], l);
177
315
  }
178
316
  function h(l) {
179
317
  c("next", l);
@@ -185,7 +323,7 @@ function Ye(n, t, e) {
185
323
  l(f), o.shift(), o.length && c(o[0][0], o[0][1]);
186
324
  }
187
325
  }
188
- function Xe(n) {
326
+ function tt(n) {
189
327
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
190
328
  var t = n[Symbol.asyncIterator], e;
191
329
  return t ? t.call(n) : (n = typeof k == "function" ? k(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
@@ -207,13 +345,13 @@ function Xe(n) {
207
345
  function g(n) {
208
346
  return typeof n == "function";
209
347
  }
210
- function ye(n) {
348
+ function Se(n) {
211
349
  var t = function(r) {
212
350
  Error.call(r), r.stack = new Error().stack;
213
351
  }, e = n(t);
214
352
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
215
353
  }
216
- var z = ye(function(n) {
354
+ var z = Se(function(n) {
217
355
  return function(e) {
218
356
  n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
219
357
  ` + e.map(function(r, s) {
@@ -269,7 +407,7 @@ var R = (function() {
269
407
  for (var b = k(m), l = b.next(); !l.done; l = b.next()) {
270
408
  var f = l.value;
271
409
  try {
272
- ie(f);
410
+ ce(f);
273
411
  } catch (p) {
274
412
  o = o ?? [], p instanceof z ? o = H(H([], D(o)), D(p.errors)) : o.push(p);
275
413
  }
@@ -291,7 +429,7 @@ var R = (function() {
291
429
  var e;
292
430
  if (t && t !== this)
293
431
  if (this.closed)
294
- ie(t);
432
+ ce(t);
295
433
  else {
296
434
  if (t instanceof n) {
297
435
  if (t.closed || t._hasParent(this))
@@ -316,16 +454,16 @@ var R = (function() {
316
454
  var t = new n();
317
455
  return t.closed = !0, t;
318
456
  })(), n;
319
- })(), Se = R.EMPTY;
320
- function we(n) {
457
+ })(), we = R.EMPTY;
458
+ function Ee(n) {
321
459
  return n instanceof R || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
322
460
  }
323
- function ie(n) {
461
+ function ce(n) {
324
462
  g(n) ? n() : n.unsubscribe();
325
463
  }
326
- var Ve = {
464
+ var nt = {
327
465
  Promise: void 0
328
- }, We = {
466
+ }, rt = {
329
467
  setTimeout: function(n, t) {
330
468
  for (var e = [], r = 2; r < arguments.length; r++)
331
469
  e[r - 2] = arguments[r];
@@ -336,12 +474,12 @@ var Ve = {
336
474
  },
337
475
  delegate: void 0
338
476
  };
339
- function Ee(n) {
340
- We.setTimeout(function() {
477
+ function Ie(n) {
478
+ rt.setTimeout(function() {
341
479
  throw n;
342
480
  });
343
481
  }
344
- function Z() {
482
+ function ee() {
345
483
  }
346
484
  function B(n) {
347
485
  n();
@@ -350,10 +488,10 @@ var ne = (function(n) {
350
488
  T(t, n);
351
489
  function t(e) {
352
490
  var r = n.call(this) || this;
353
- return r.isStopped = !1, e ? (r.destination = e, we(e) && e.add(r)) : r.destination = Qe, r;
491
+ return r.isStopped = !1, e ? (r.destination = e, Ee(e) && e.add(r)) : r.destination = it, r;
354
492
  }
355
493
  return t.create = function(e, r, s) {
356
- return new ee(e, r, s);
494
+ return new te(e, r, s);
357
495
  }, t.prototype.next = function(e) {
358
496
  this.isStopped || this._next(e);
359
497
  }, t.prototype.error = function(e) {
@@ -377,7 +515,7 @@ var ne = (function(n) {
377
515
  this.unsubscribe();
378
516
  }
379
517
  }, t;
380
- })(R), ze = (function() {
518
+ })(R), st = (function() {
381
519
  function n(t) {
382
520
  this.partialObserver = t;
383
521
  }
@@ -408,7 +546,7 @@ var ne = (function(n) {
408
546
  G(e);
409
547
  }
410
548
  }, n;
411
- })(), ee = (function(n) {
549
+ })(), te = (function(n) {
412
550
  T(t, n);
413
551
  function t(e, r, s) {
414
552
  var o = n.call(this) || this, i;
@@ -416,28 +554,28 @@ var ne = (function(n) {
416
554
  next: e ?? void 0,
417
555
  error: r ?? void 0,
418
556
  complete: s ?? void 0
419
- } : i = e, o.destination = new ze(i), o;
557
+ } : i = e, o.destination = new st(i), o;
420
558
  }
421
559
  return t;
422
560
  })(ne);
423
561
  function G(n) {
424
- Ee(n);
562
+ Ie(n);
425
563
  }
426
- function Je(n) {
564
+ function ot(n) {
427
565
  throw n;
428
566
  }
429
- var Qe = {
567
+ var it = {
430
568
  closed: !0,
431
- next: Z,
432
- error: Je,
433
- complete: Z
569
+ next: ee,
570
+ error: ot,
571
+ complete: ee
434
572
  }, re = (function() {
435
573
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
436
574
  })();
437
575
  function X(n) {
438
576
  return n;
439
577
  }
440
- function Ze(n) {
578
+ function at(n) {
441
579
  return n.length === 0 ? X : n.length === 1 ? n[0] : function(e) {
442
580
  return n.reduce(function(r, s) {
443
581
  return s(r);
@@ -452,7 +590,7 @@ var S = (function() {
452
590
  var e = new n();
453
591
  return e.source = this, e.operator = t, e;
454
592
  }, n.prototype.subscribe = function(t, e, r) {
455
- var s = this, o = tt(t) ? t : new ee(t, e, r);
593
+ var s = this, o = ut(t) ? t : new te(t, e, r);
456
594
  return B(function() {
457
595
  var i = s, a = i.operator, c = i.source;
458
596
  o.add(a ? a.call(o, c) : c ? s._subscribe(o) : s._trySubscribe(o));
@@ -465,8 +603,8 @@ var S = (function() {
465
603
  }
466
604
  }, n.prototype.forEach = function(t, e) {
467
605
  var r = this;
468
- return e = ae(e), new e(function(s, o) {
469
- var i = new ee({
606
+ return e = ue(e), new e(function(s, o) {
607
+ var i = new te({
470
608
  next: function(a) {
471
609
  try {
472
610
  t(a);
@@ -487,10 +625,10 @@ var S = (function() {
487
625
  }, n.prototype.pipe = function() {
488
626
  for (var t = [], e = 0; e < arguments.length; e++)
489
627
  t[e] = arguments[e];
490
- return Ze(t)(this);
628
+ return at(t)(this);
491
629
  }, n.prototype.toPromise = function(t) {
492
630
  var e = this;
493
- return t = ae(t), new t(function(r, s) {
631
+ return t = ue(t), new t(function(r, s) {
494
632
  var o;
495
633
  e.subscribe(function(i) {
496
634
  return o = i;
@@ -504,22 +642,22 @@ var S = (function() {
504
642
  return new n(t);
505
643
  }, n;
506
644
  })();
507
- function ae(n) {
645
+ function ue(n) {
508
646
  var t;
509
- return (t = n ?? Ve.Promise) !== null && t !== void 0 ? t : Promise;
647
+ return (t = n ?? nt.Promise) !== null && t !== void 0 ? t : Promise;
510
648
  }
511
- function et(n) {
649
+ function ct(n) {
512
650
  return n && g(n.next) && g(n.error) && g(n.complete);
513
651
  }
514
- function tt(n) {
515
- return n && n instanceof ne || et(n) && we(n);
652
+ function ut(n) {
653
+ return n && n instanceof ne || ct(n) && Ee(n);
516
654
  }
517
- function nt(n) {
655
+ function lt(n) {
518
656
  return g(n?.lift);
519
657
  }
520
658
  function A(n) {
521
659
  return function(t) {
522
- if (nt(t))
660
+ if (lt(t))
523
661
  return t.lift(function(e) {
524
662
  try {
525
663
  return n(e, this);
@@ -531,9 +669,9 @@ function A(n) {
531
669
  };
532
670
  }
533
671
  function O(n, t, e, r, s) {
534
- return new rt(n, t, e, r, s);
672
+ return new dt(n, t, e, r, s);
535
673
  }
536
- var rt = (function(n) {
674
+ var dt = (function(n) {
537
675
  T(t, n);
538
676
  function t(e, r, s, o, i, a) {
539
677
  var c = n.call(this, e) || this;
@@ -568,7 +706,7 @@ var rt = (function(n) {
568
706
  n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
569
707
  }
570
708
  }, t;
571
- })(ne), st = ye(function(n) {
709
+ })(ne), ht = Se(function(n) {
572
710
  return function() {
573
711
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
574
712
  };
@@ -579,11 +717,11 @@ var rt = (function(n) {
579
717
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
580
718
  }
581
719
  return t.prototype.lift = function(e) {
582
- var r = new ce(this, this);
720
+ var r = new le(this, this);
583
721
  return r.operator = e, r;
584
722
  }, t.prototype._throwIfClosed = function() {
585
723
  if (this.closed)
586
- throw new st();
724
+ throw new ht();
587
725
  }, t.prototype.next = function(e) {
588
726
  var r = this;
589
727
  B(function() {
@@ -639,7 +777,7 @@ var rt = (function(n) {
639
777
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
640
778
  }, t.prototype._innerSubscribe = function(e) {
641
779
  var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
642
- return o || i ? Se : (this.currentObservers = null, a.push(e), new R(function() {
780
+ return o || i ? we : (this.currentObservers = null, a.push(e), new R(function() {
643
781
  r.currentObservers = null, q(a, e);
644
782
  }));
645
783
  }, t.prototype._checkFinalizedStatuses = function(e) {
@@ -649,9 +787,9 @@ var rt = (function(n) {
649
787
  var e = new S();
650
788
  return e.source = this, e;
651
789
  }, t.create = function(e, r) {
652
- return new ce(e, r);
790
+ return new le(e, r);
653
791
  }, t;
654
- })(S), ce = (function(n) {
792
+ })(S), le = (function(n) {
655
793
  T(t, n);
656
794
  function t(e, r) {
657
795
  var s = n.call(this) || this;
@@ -668,7 +806,7 @@ var rt = (function(n) {
668
806
  (r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
669
807
  }, t.prototype._subscribe = function(e) {
670
808
  var r, s;
671
- return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Se;
809
+ return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : we;
672
810
  }, t;
673
811
  })(se), P = (function(n) {
674
812
  T(t, n);
@@ -693,11 +831,11 @@ var rt = (function(n) {
693
831
  }, t.prototype.next = function(e) {
694
832
  n.prototype.next.call(this, this._value = e);
695
833
  }, t;
696
- })(se), ot = {
834
+ })(se), ft = {
697
835
  now: function() {
698
836
  return Date.now();
699
837
  }
700
- }, it = (function(n) {
838
+ }, pt = (function(n) {
701
839
  T(t, n);
702
840
  function t(e, r) {
703
841
  return n.call(this) || this;
@@ -705,7 +843,7 @@ var rt = (function(n) {
705
843
  return t.prototype.schedule = function(e, r) {
706
844
  return this;
707
845
  }, t;
708
- })(R), ue = {
846
+ })(R), de = {
709
847
  setInterval: function(n, t) {
710
848
  for (var e = [], r = 2; r < arguments.length; r++)
711
849
  e[r - 2] = arguments[r];
@@ -715,7 +853,7 @@ var rt = (function(n) {
715
853
  return clearInterval(n);
716
854
  },
717
855
  delegate: void 0
718
- }, at = (function(n) {
856
+ }, mt = (function(n) {
719
857
  T(t, n);
720
858
  function t(e, r) {
721
859
  var s = n.call(this, e, r) || this;
@@ -729,11 +867,11 @@ var rt = (function(n) {
729
867
  var o = this.id, i = this.scheduler;
730
868
  return o != null && (this.id = this.recycleAsyncId(i, o, r)), this.pending = !0, this.delay = r, this.id = (s = this.id) !== null && s !== void 0 ? s : this.requestAsyncId(i, this.id, r), this;
731
869
  }, t.prototype.requestAsyncId = function(e, r, s) {
732
- return s === void 0 && (s = 0), ue.setInterval(e.flush.bind(e, this), s);
870
+ return s === void 0 && (s = 0), de.setInterval(e.flush.bind(e, this), s);
733
871
  }, t.prototype.recycleAsyncId = function(e, r, s) {
734
872
  if (s === void 0 && (s = 0), s != null && this.delay === s && this.pending === !1)
735
873
  return r;
736
- r != null && ue.clearInterval(r);
874
+ r != null && de.clearInterval(r);
737
875
  }, t.prototype.execute = function(e, r) {
738
876
  if (this.closed)
739
877
  return new Error("executing a cancelled action");
@@ -757,17 +895,17 @@ var rt = (function(n) {
757
895
  this.work = this.state = this.scheduler = null, this.pending = !1, q(o, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
758
896
  }
759
897
  }, t;
760
- })(it), le = (function() {
898
+ })(pt), he = (function() {
761
899
  function n(t, e) {
762
900
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
763
901
  }
764
902
  return n.prototype.schedule = function(t, e, r) {
765
903
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
766
- }, n.now = ot.now, n;
767
- })(), ct = (function(n) {
904
+ }, n.now = ft.now, n;
905
+ })(), gt = (function(n) {
768
906
  T(t, n);
769
907
  function t(e, r) {
770
- r === void 0 && (r = le.now);
908
+ r === void 0 && (r = he.now);
771
909
  var s = n.call(this, e, r) || this;
772
910
  return s.actions = [], s._active = !1, s;
773
911
  }
@@ -789,60 +927,60 @@ var rt = (function(n) {
789
927
  throw s;
790
928
  }
791
929
  }, t;
792
- })(le), Ie = new ct(at), ut = Ie, lt = new S(function(n) {
930
+ })(he), Te = new gt(mt), bt = Te, vt = new S(function(n) {
793
931
  return n.complete();
794
932
  });
795
- function Te(n) {
933
+ function xe(n) {
796
934
  return n && g(n.schedule);
797
935
  }
798
- function xe(n) {
936
+ function Ce(n) {
799
937
  return n[n.length - 1];
800
938
  }
801
- function dt(n) {
802
- return g(xe(n)) ? n.pop() : void 0;
939
+ function yt(n) {
940
+ return g(Ce(n)) ? n.pop() : void 0;
803
941
  }
804
- function Ce(n) {
805
- return Te(xe(n)) ? n.pop() : void 0;
942
+ function Oe(n) {
943
+ return xe(Ce(n)) ? n.pop() : void 0;
806
944
  }
807
- var Oe = (function(n) {
945
+ var Ae = (function(n) {
808
946
  return n && typeof n.length == "number" && typeof n != "function";
809
947
  });
810
- function Ae(n) {
948
+ function Le(n) {
811
949
  return g(n?.then);
812
950
  }
813
- function Le(n) {
951
+ function _e(n) {
814
952
  return g(n[re]);
815
953
  }
816
- function _e(n) {
954
+ function Pe(n) {
817
955
  return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
818
956
  }
819
- function Pe(n) {
957
+ function Ue(n) {
820
958
  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.");
821
959
  }
822
- function ht() {
960
+ function St() {
823
961
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
824
962
  }
825
- var Me = ht();
826
- function Ue(n) {
963
+ var Me = St();
964
+ function ke(n) {
827
965
  return g(n?.[Me]);
828
966
  }
829
- function ke(n) {
830
- return Ye(this, arguments, function() {
967
+ function Ne(n) {
968
+ return et(this, arguments, function() {
831
969
  var e, r, s, o;
832
- return ve(this, function(i) {
970
+ return ye(this, function(i) {
833
971
  switch (i.label) {
834
972
  case 0:
835
973
  e = n.getReader(), i.label = 1;
836
974
  case 1:
837
975
  i.trys.push([1, , 9, 10]), i.label = 2;
838
976
  case 2:
839
- return [4, U(e.read())];
977
+ return [4, M(e.read())];
840
978
  case 3:
841
- return r = i.sent(), s = r.value, o = r.done, o ? [4, U(void 0)] : [3, 5];
979
+ return r = i.sent(), s = r.value, o = r.done, o ? [4, M(void 0)] : [3, 5];
842
980
  case 4:
843
981
  return [2, i.sent()];
844
982
  case 5:
845
- return [4, U(s)];
983
+ return [4, M(s)];
846
984
  case 6:
847
985
  return [4, i.sent()];
848
986
  case 7:
@@ -857,29 +995,29 @@ function ke(n) {
857
995
  });
858
996
  });
859
997
  }
860
- function Ne(n) {
998
+ function Re(n) {
861
999
  return g(n?.getReader);
862
1000
  }
863
- function M(n) {
1001
+ function U(n) {
864
1002
  if (n instanceof S)
865
1003
  return n;
866
1004
  if (n != null) {
867
- if (Le(n))
868
- return ft(n);
869
- if (Oe(n))
870
- return pt(n);
871
- if (Ae(n))
872
- return mt(n);
873
1005
  if (_e(n))
874
- return Re(n);
875
- if (Ue(n))
876
- return gt(n);
877
- if (Ne(n))
878
- return bt(n);
1006
+ return wt(n);
1007
+ if (Ae(n))
1008
+ return Et(n);
1009
+ if (Le(n))
1010
+ return It(n);
1011
+ if (Pe(n))
1012
+ return $e(n);
1013
+ if (ke(n))
1014
+ return Tt(n);
1015
+ if (Re(n))
1016
+ return xt(n);
879
1017
  }
880
- throw Pe(n);
1018
+ throw Ue(n);
881
1019
  }
882
- function ft(n) {
1020
+ function wt(n) {
883
1021
  return new S(function(t) {
884
1022
  var e = n[re]();
885
1023
  if (g(e.subscribe))
@@ -887,23 +1025,23 @@ function ft(n) {
887
1025
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
888
1026
  });
889
1027
  }
890
- function pt(n) {
1028
+ function Et(n) {
891
1029
  return new S(function(t) {
892
1030
  for (var e = 0; e < n.length && !t.closed; e++)
893
1031
  t.next(n[e]);
894
1032
  t.complete();
895
1033
  });
896
1034
  }
897
- function mt(n) {
1035
+ function It(n) {
898
1036
  return new S(function(t) {
899
1037
  n.then(function(e) {
900
1038
  t.closed || (t.next(e), t.complete());
901
1039
  }, function(e) {
902
1040
  return t.error(e);
903
- }).then(null, Ee);
1041
+ }).then(null, Ie);
904
1042
  });
905
1043
  }
906
- function gt(n) {
1044
+ function Tt(n) {
907
1045
  return new S(function(t) {
908
1046
  var e, r;
909
1047
  try {
@@ -924,24 +1062,24 @@ function gt(n) {
924
1062
  t.complete();
925
1063
  });
926
1064
  }
927
- function Re(n) {
1065
+ function $e(n) {
928
1066
  return new S(function(t) {
929
- vt(n, t).catch(function(e) {
1067
+ Ct(n, t).catch(function(e) {
930
1068
  return t.error(e);
931
1069
  });
932
1070
  });
933
1071
  }
934
- function bt(n) {
935
- return Re(ke(n));
1072
+ function xt(n) {
1073
+ return $e(Ne(n));
936
1074
  }
937
- function vt(n, t) {
1075
+ function Ct(n, t) {
938
1076
  var e, r, s, o;
939
- return qe(this, void 0, void 0, function() {
1077
+ return Ze(this, void 0, void 0, function() {
940
1078
  var i, a;
941
- return ve(this, function(c) {
1079
+ return ye(this, function(c) {
942
1080
  switch (c.label) {
943
1081
  case 0:
944
- c.trys.push([0, 5, 6, 11]), e = Xe(n), c.label = 1;
1082
+ c.trys.push([0, 5, 6, 11]), e = tt(n), c.label = 1;
945
1083
  case 1:
946
1084
  return [4, e.next()];
947
1085
  case 2:
@@ -980,7 +1118,7 @@ function C(n, t, e, r, s) {
980
1118
  if (n.add(o), !s)
981
1119
  return o;
982
1120
  }
983
- function $e(n, t) {
1121
+ function je(n, t) {
984
1122
  return t === void 0 && (t = 0), A(function(e, r) {
985
1123
  e.subscribe(O(r, function(s) {
986
1124
  return C(r, n, function() {
@@ -997,20 +1135,20 @@ function $e(n, t) {
997
1135
  }));
998
1136
  });
999
1137
  }
1000
- function je(n, t) {
1138
+ function De(n, t) {
1001
1139
  return t === void 0 && (t = 0), A(function(e, r) {
1002
1140
  r.add(n.schedule(function() {
1003
1141
  return e.subscribe(r);
1004
1142
  }, t));
1005
1143
  });
1006
1144
  }
1007
- function yt(n, t) {
1008
- return M(n).pipe(je(t), $e(t));
1145
+ function Ot(n, t) {
1146
+ return U(n).pipe(De(t), je(t));
1009
1147
  }
1010
- function St(n, t) {
1011
- return M(n).pipe(je(t), $e(t));
1148
+ function At(n, t) {
1149
+ return U(n).pipe(De(t), je(t));
1012
1150
  }
1013
- function wt(n, t) {
1151
+ function Lt(n, t) {
1014
1152
  return new S(function(e) {
1015
1153
  var r = 0;
1016
1154
  return t.schedule(function() {
@@ -1018,7 +1156,7 @@ function wt(n, t) {
1018
1156
  });
1019
1157
  });
1020
1158
  }
1021
- function Et(n, t) {
1159
+ function _t(n, t) {
1022
1160
  return new S(function(e) {
1023
1161
  var r;
1024
1162
  return C(e, t, function() {
@@ -1037,7 +1175,7 @@ function Et(n, t) {
1037
1175
  };
1038
1176
  });
1039
1177
  }
1040
- function De(n, t) {
1178
+ function He(n, t) {
1041
1179
  if (!n)
1042
1180
  throw new Error("Iterable cannot be null");
1043
1181
  return new S(function(e) {
@@ -1051,36 +1189,36 @@ function De(n, t) {
1051
1189
  });
1052
1190
  });
1053
1191
  }
1054
- function It(n, t) {
1055
- return De(ke(n), t);
1192
+ function Pt(n, t) {
1193
+ return He(Ne(n), t);
1056
1194
  }
1057
- function Tt(n, t) {
1195
+ function Ut(n, t) {
1058
1196
  if (n != null) {
1059
- if (Le(n))
1060
- return yt(n, t);
1061
- if (Oe(n))
1062
- return wt(n, t);
1063
- if (Ae(n))
1064
- return St(n, t);
1065
1197
  if (_e(n))
1066
- return De(n, t);
1067
- if (Ue(n))
1068
- return Et(n, t);
1069
- if (Ne(n))
1070
- return It(n, t);
1198
+ return Ot(n, t);
1199
+ if (Ae(n))
1200
+ return Lt(n, t);
1201
+ if (Le(n))
1202
+ return At(n, t);
1203
+ if (Pe(n))
1204
+ return He(n, t);
1205
+ if (ke(n))
1206
+ return _t(n, t);
1207
+ if (Re(n))
1208
+ return Pt(n, t);
1071
1209
  }
1072
- throw Pe(n);
1210
+ throw Ue(n);
1073
1211
  }
1074
1212
  function oe(n, t) {
1075
- return t ? Tt(n, t) : M(n);
1213
+ return t ? Ut(n, t) : U(n);
1076
1214
  }
1077
- function xt() {
1215
+ function Mt() {
1078
1216
  for (var n = [], t = 0; t < arguments.length; t++)
1079
1217
  n[t] = arguments[t];
1080
- var e = Ce(n);
1218
+ var e = Oe(n);
1081
1219
  return oe(n, e);
1082
1220
  }
1083
- function Ct(n) {
1221
+ function kt(n) {
1084
1222
  return n instanceof Date && !isNaN(n);
1085
1223
  }
1086
1224
  function N(n, t) {
@@ -1091,23 +1229,23 @@ function N(n, t) {
1091
1229
  }));
1092
1230
  });
1093
1231
  }
1094
- var Ot = Array.isArray;
1095
- function At(n, t) {
1096
- return Ot(t) ? n.apply(void 0, H([], D(t))) : n(t);
1232
+ var Nt = Array.isArray;
1233
+ function Rt(n, t) {
1234
+ return Nt(t) ? n.apply(void 0, H([], D(t))) : n(t);
1097
1235
  }
1098
- function Lt(n) {
1236
+ function $t(n) {
1099
1237
  return N(function(t) {
1100
- return At(n, t);
1238
+ return Rt(n, t);
1101
1239
  });
1102
1240
  }
1103
- var _t = Array.isArray, Pt = Object.getPrototypeOf, Mt = Object.prototype, Ut = Object.keys;
1104
- function kt(n) {
1241
+ var jt = Array.isArray, Dt = Object.getPrototypeOf, Ht = Object.prototype, Ft = Object.keys;
1242
+ function Gt(n) {
1105
1243
  if (n.length === 1) {
1106
1244
  var t = n[0];
1107
- if (_t(t))
1245
+ if (jt(t))
1108
1246
  return { args: t, keys: null };
1109
- if (Nt(t)) {
1110
- var e = Ut(t);
1247
+ if (Bt(t)) {
1248
+ var e = Ft(t);
1111
1249
  return {
1112
1250
  args: e.map(function(r) {
1113
1251
  return t[r];
@@ -1118,30 +1256,30 @@ function kt(n) {
1118
1256
  }
1119
1257
  return { args: n, keys: null };
1120
1258
  }
1121
- function Nt(n) {
1122
- return n && typeof n == "object" && Pt(n) === Mt;
1259
+ function Bt(n) {
1260
+ return n && typeof n == "object" && Dt(n) === Ht;
1123
1261
  }
1124
- function Rt(n, t) {
1262
+ function Kt(n, t) {
1125
1263
  return n.reduce(function(e, r, s) {
1126
1264
  return e[r] = t[s], e;
1127
1265
  }, {});
1128
1266
  }
1129
- function $t() {
1267
+ function qt() {
1130
1268
  for (var n = [], t = 0; t < arguments.length; t++)
1131
1269
  n[t] = arguments[t];
1132
- var e = Ce(n), r = dt(n), s = kt(n), o = s.args, i = s.keys;
1270
+ var e = Oe(n), r = yt(n), s = Gt(n), o = s.args, i = s.keys;
1133
1271
  if (o.length === 0)
1134
1272
  return oe([], e);
1135
- var a = new S(jt(o, e, i ? function(c) {
1136
- return Rt(i, c);
1273
+ var a = new S(Yt(o, e, i ? function(c) {
1274
+ return Kt(i, c);
1137
1275
  } : X));
1138
- return r ? a.pipe(Lt(r)) : a;
1276
+ return r ? a.pipe($t(r)) : a;
1139
1277
  }
1140
- function jt(n, t, e) {
1278
+ function Yt(n, t, e) {
1141
1279
  return e === void 0 && (e = X), function(r) {
1142
- de(t, function() {
1280
+ fe(t, function() {
1143
1281
  for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
1144
- de(t, function() {
1282
+ fe(t, function() {
1145
1283
  var m = oe(n[h], t), b = !1;
1146
1284
  m.subscribe(O(r, function(l) {
1147
1285
  o[h] = l, b || (b = !0, a--), a || r.next(e(o.slice()));
@@ -1154,10 +1292,10 @@ function jt(n, t, e) {
1154
1292
  }, r);
1155
1293
  };
1156
1294
  }
1157
- function de(n, t, e) {
1295
+ function fe(n, t, e) {
1158
1296
  n ? C(e, n, t) : t();
1159
1297
  }
1160
- function Dt(n, t, e, r, s, o, i, a) {
1298
+ function Xt(n, t, e, r, s, o, i, a) {
1161
1299
  var c = [], u = 0, h = 0, m = !1, b = function() {
1162
1300
  m && !c.length && !u && t.complete();
1163
1301
  }, l = function(p) {
@@ -1165,19 +1303,19 @@ function Dt(n, t, e, r, s, o, i, a) {
1165
1303
  }, f = function(p) {
1166
1304
  u++;
1167
1305
  var L = !1;
1168
- M(e(p, h++)).subscribe(O(t, function(w) {
1169
- t.next(w);
1306
+ U(e(p, h++)).subscribe(O(t, function(E) {
1307
+ t.next(E);
1170
1308
  }, function() {
1171
1309
  L = !0;
1172
1310
  }, void 0, function() {
1173
1311
  if (L)
1174
1312
  try {
1175
1313
  u--;
1176
- for (var w = function() {
1314
+ for (var E = function() {
1177
1315
  var _ = c.shift();
1178
1316
  i || f(_);
1179
1317
  }; c.length && u < r; )
1180
- w();
1318
+ E();
1181
1319
  b();
1182
1320
  } catch (_) {
1183
1321
  t.error(_);
@@ -1193,16 +1331,16 @@ function Y(n, t, e) {
1193
1331
  return e === void 0 && (e = 1 / 0), g(t) ? Y(function(r, s) {
1194
1332
  return N(function(o, i) {
1195
1333
  return t(r, o, s, i);
1196
- })(M(n(r, s)));
1334
+ })(U(n(r, s)));
1197
1335
  }, e) : (typeof t == "number" && (e = t), A(function(r, s) {
1198
- return Dt(r, s, n, e);
1336
+ return Xt(r, s, n, e);
1199
1337
  }));
1200
1338
  }
1201
- function Ht(n, t, e) {
1202
- n === void 0 && (n = 0), e === void 0 && (e = ut);
1339
+ function Vt(n, t, e) {
1340
+ n === void 0 && (n = 0), e === void 0 && (e = bt);
1203
1341
  var r = -1;
1204
- return t != null && (Te(t) ? e = t : r = t), new S(function(s) {
1205
- var o = Ct(n) ? +n - e.now() : n;
1342
+ return t != null && (xe(t) ? e = t : r = t), new S(function(s) {
1343
+ var o = kt(n) ? +n - e.now() : n;
1206
1344
  o < 0 && (o = 0);
1207
1345
  var i = 0;
1208
1346
  return e.schedule(function() {
@@ -1210,12 +1348,12 @@ function Ht(n, t, e) {
1210
1348
  }, o);
1211
1349
  });
1212
1350
  }
1213
- function Ft(n, t) {
1351
+ function Wt(n, t) {
1214
1352
  return g(t) ? Y(n, t, 1) : Y(n, 1);
1215
1353
  }
1216
- function Gt(n) {
1354
+ function zt(n) {
1217
1355
  return n <= 0 ? function() {
1218
- return lt;
1356
+ return vt;
1219
1357
  } : A(function(t, e) {
1220
1358
  var r = 0;
1221
1359
  t.subscribe(O(e, function(s) {
@@ -1223,25 +1361,25 @@ function Gt(n) {
1223
1361
  }));
1224
1362
  });
1225
1363
  }
1226
- function Bt(n) {
1364
+ function Jt(n) {
1227
1365
  return N(function() {
1228
1366
  return n;
1229
1367
  });
1230
1368
  }
1231
- function Kt(n, t) {
1369
+ function Qt(n, t) {
1232
1370
  return Y(function(e, r) {
1233
- return M(n(e, r)).pipe(Gt(1), Bt(e));
1371
+ return U(n(e, r)).pipe(zt(1), Jt(e));
1234
1372
  });
1235
1373
  }
1236
- function qt(n, t) {
1237
- t === void 0 && (t = Ie);
1238
- var e = Ht(n, t);
1239
- return Kt(function() {
1374
+ function Zt(n, t) {
1375
+ t === void 0 && (t = Te);
1376
+ var e = Vt(n, t);
1377
+ return Qt(function() {
1240
1378
  return e;
1241
1379
  });
1242
1380
  }
1243
1381
  function j(n, t) {
1244
- return t === void 0 && (t = X), n = n ?? Yt, A(function(e, r) {
1382
+ return t === void 0 && (t = X), n = n ?? en, A(function(e, r) {
1245
1383
  var s, o = !0;
1246
1384
  e.subscribe(O(r, function(i) {
1247
1385
  var a = t(i);
@@ -1249,10 +1387,10 @@ function j(n, t) {
1249
1387
  }));
1250
1388
  });
1251
1389
  }
1252
- function Yt(n, t) {
1390
+ function en(n, t) {
1253
1391
  return n === t;
1254
1392
  }
1255
- function Xt(n) {
1393
+ function tn(n) {
1256
1394
  return A(function(t, e) {
1257
1395
  try {
1258
1396
  t.subscribe(e);
@@ -1261,140 +1399,13 @@ function Xt(n) {
1261
1399
  }
1262
1400
  });
1263
1401
  }
1264
- function Vt(n) {
1402
+ function nn(n) {
1265
1403
  return A(function(t, e) {
1266
- M(n).subscribe(O(e, function() {
1404
+ U(n).subscribe(O(e, function() {
1267
1405
  return e.complete();
1268
- }, Z)), !e.closed && t.subscribe(e);
1406
+ }, ee)), !e.closed && t.subscribe(e);
1269
1407
  });
1270
1408
  }
1271
- async function Wt(n, t) {
1272
- const e = n.getReader();
1273
- let r;
1274
- for (; !(r = await e.read()).done; )
1275
- t(r.value);
1276
- }
1277
- function zt(n) {
1278
- let t, e, r, s = !1;
1279
- return function(i) {
1280
- t === void 0 ? (t = i, e = 0, r = -1) : t = Qt(t, i);
1281
- const a = t.length;
1282
- let c = 0;
1283
- for (; e < a; ) {
1284
- s && (t[e] === 10 && (c = ++e), s = !1);
1285
- let u = -1;
1286
- for (; e < a && u === -1; ++e)
1287
- switch (t[e]) {
1288
- case 58:
1289
- r === -1 && (r = e - c);
1290
- break;
1291
- case 13:
1292
- s = !0;
1293
- case 10:
1294
- u = e;
1295
- break;
1296
- }
1297
- if (u === -1)
1298
- break;
1299
- n(t.subarray(c, u), r), c = e, r = -1;
1300
- }
1301
- c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
1302
- };
1303
- }
1304
- function Jt(n, t, e) {
1305
- let r = he();
1306
- const s = new TextDecoder();
1307
- return function(i, a) {
1308
- if (i.length === 0)
1309
- e?.(r), r = he();
1310
- else if (a > 0) {
1311
- const c = s.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(u));
1312
- switch (c) {
1313
- case "data":
1314
- r.data = r.data ? r.data + `
1315
- ` + h : h;
1316
- break;
1317
- case "event":
1318
- r.event = h;
1319
- break;
1320
- case "id":
1321
- n(r.id = h);
1322
- break;
1323
- case "retry":
1324
- const m = parseInt(h, 10);
1325
- isNaN(m) || t(r.retry = m);
1326
- break;
1327
- }
1328
- }
1329
- };
1330
- }
1331
- function Qt(n, t) {
1332
- const e = new Uint8Array(n.length + t.length);
1333
- return e.set(n), e.set(t, n.length), e;
1334
- }
1335
- function he() {
1336
- return {
1337
- data: "",
1338
- event: "",
1339
- id: "",
1340
- retry: void 0
1341
- };
1342
- }
1343
- var Zt = function(n, t) {
1344
- var e = {};
1345
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
1346
- if (n != null && typeof Object.getOwnPropertySymbols == "function")
1347
- for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
1348
- t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
1349
- return e;
1350
- };
1351
- const te = "text/event-stream", en = 1e3, fe = "last-event-id";
1352
- function tn(n, t) {
1353
- var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = Zt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1354
- return new Promise((m, b) => {
1355
- const l = Object.assign({}, r);
1356
- l.accept || (l.accept = te);
1357
- let f;
1358
- function p() {
1359
- f.abort(), document.hidden || V();
1360
- }
1361
- c || document.addEventListener("visibilitychange", p);
1362
- let L = en, w = 0;
1363
- function _() {
1364
- document.removeEventListener("visibilitychange", p), window.clearTimeout(w), f.abort();
1365
- }
1366
- e?.addEventListener("abort", () => {
1367
- _(), m();
1368
- });
1369
- const Fe = u ?? window.fetch, Ge = s ?? nn;
1370
- async function V() {
1371
- var W;
1372
- f = new AbortController();
1373
- try {
1374
- const F = await Fe(n, Object.assign(Object.assign({}, h), { headers: l, signal: f.signal }));
1375
- await Ge(F), await Wt(F.body, zt(Jt((x) => {
1376
- x ? l[fe] = x : delete l[fe];
1377
- }, (x) => {
1378
- L = x;
1379
- }, o))), i?.(), _(), m();
1380
- } catch (F) {
1381
- if (!f.signal.aborted)
1382
- try {
1383
- const x = (W = a?.(F)) !== null && W !== void 0 ? W : L;
1384
- window.clearTimeout(w), w = window.setTimeout(V, x);
1385
- } catch (x) {
1386
- _(), b(x);
1387
- }
1388
- }
1389
- }
1390
- V();
1391
- });
1392
- }
1393
- function nn(n) {
1394
- const t = n.headers.get("content-type");
1395
- if (!t?.startsWith(te))
1396
- throw new Error(`Expected content-type to be ${te}, Actual: ${t}`);
1397
- }
1398
1409
  function pe(n) {
1399
1410
  const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: o } = n, i = n.method ?? "POST";
1400
1411
  return new S((a) => {
@@ -1406,7 +1417,7 @@ function pe(n) {
1406
1417
  };
1407
1418
  e && (m["X-API-KEY"] = e);
1408
1419
  const b = new URL(t);
1409
- return s && b.searchParams.set("is_debug", "true"), tn(b.toString(), {
1420
+ return s && b.searchParams.set("is_debug", "true"), ve(b.toString(), {
1410
1421
  method: i,
1411
1422
  headers: m,
1412
1423
  body: i === "POST" && r ? JSON.stringify(r) : void 0,
@@ -1430,7 +1441,7 @@ function pe(n) {
1430
1441
  f = null;
1431
1442
  }
1432
1443
  }
1433
- a.error(new I(l.status, l.statusText, f)), c.abort();
1444
+ a.error(new w(l.status, l.statusText, f)), c.abort();
1434
1445
  }
1435
1446
  },
1436
1447
  onmessage: (l) => {
@@ -1583,7 +1594,7 @@ class xn {
1583
1594
  if (o.status === 404)
1584
1595
  return null;
1585
1596
  if (!o.ok)
1586
- throw new I(o.status, o.statusText, await o.text().catch(() => {
1597
+ throw new w(o.status, o.statusText, await o.text().catch(() => {
1587
1598
  }));
1588
1599
  const i = await o.json(), a = i.data ?? i;
1589
1600
  return {
@@ -1606,11 +1617,11 @@ class xn {
1606
1617
  // No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
1607
1618
  // run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
1608
1619
  // create-sse-observable); a no-cursor failure surfaces via `error` below.
1609
- Ft((r) => xt(r).pipe(qt(e?.delayTime ?? 50))),
1610
- Vt(this.destroy$),
1620
+ Wt((r) => Mt(r).pipe(Zt(e?.delayTime ?? 50))),
1621
+ nn(this.destroy$),
1611
1622
  // Settle the run accounting on every termination path — complete, error, AND a user-initiated
1612
1623
  // unsubscribe (stop-generation aborts the connection without a terminal event).
1613
- Xt(() => this.onRunSettled())
1624
+ tn(() => this.onRunSettled())
1614
1625
  ).subscribe({
1615
1626
  next: (r) => {
1616
1627
  this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
@@ -1721,7 +1732,7 @@ class xn {
1721
1732
  this.apiKey && (s["X-API-KEY"] = this.apiKey);
1722
1733
  const o = await fetch(r, { method: "POST", headers: s });
1723
1734
  if (!o.ok)
1724
- throw new I(o.status, o.statusText, await o.text().catch(() => {
1735
+ throw new w(o.status, o.statusText, await o.text().catch(() => {
1725
1736
  }));
1726
1737
  const i = await o.json(), a = i.data?.openURL ?? i.openURL;
1727
1738
  if (!a)
@@ -1750,7 +1761,7 @@ class xn {
1750
1761
  r.searchParams.set("path", e);
1751
1762
  const s = await fetch(r.toString(), { method: "GET", headers: this.sandboxFsHeaders() });
1752
1763
  if (!s.ok)
1753
- throw new I(s.status, s.statusText, await s.text().catch(() => {
1764
+ throw new w(s.status, s.statusText, await s.text().catch(() => {
1754
1765
  }));
1755
1766
  const o = await s.json(), i = o.data ?? o;
1756
1767
  return { entries: i.entries ?? [], truncated: i.truncated ?? !1 };
@@ -1764,7 +1775,7 @@ class xn {
1764
1775
  s.searchParams.set("path", e), r?.offsetBytes != null && s.searchParams.set("offset_bytes", String(r.offsetBytes)), r?.limitBytes != null && s.searchParams.set("limit_bytes", String(r.limitBytes));
1765
1776
  const o = await fetch(s.toString(), { method: "GET", headers: this.sandboxFsHeaders() });
1766
1777
  if (!o.ok)
1767
- throw new I(o.status, o.statusText, await o.text().catch(() => {
1778
+ throw new w(o.status, o.statusText, await o.text().catch(() => {
1768
1779
  }));
1769
1780
  const i = await o.blob(), a = o.headers.get("X-Total-Bytes");
1770
1781
  return {
@@ -1784,7 +1795,7 @@ class xn {
1784
1795
  i.append("file", r instanceof Blob ? r : new Blob([r]));
1785
1796
  const a = await fetch(o.toString(), { method: "PUT", headers: this.sandboxFsHeaders(), body: i });
1786
1797
  if (!a.ok)
1787
- throw new I(a.status, a.statusText, await a.text().catch(() => {
1798
+ throw new w(a.status, a.statusText, await a.text().catch(() => {
1788
1799
  }));
1789
1800
  const c = await a.json();
1790
1801
  return { bytesWritten: (c.data ?? c).bytesWritten ?? 0 };
@@ -1795,7 +1806,7 @@ class xn {
1795
1806
  Object.entries(s).forEach(([a, c]) => o.searchParams.set(a, c));
1796
1807
  const i = await fetch(o.toString(), { method: r, headers: this.sandboxFsHeaders() });
1797
1808
  if (!i.ok)
1798
- throw new I(i.status, i.statusText, await i.text().catch(() => {
1809
+ throw new w(i.status, i.statusText, await i.text().catch(() => {
1799
1810
  }));
1800
1811
  return i.json().catch(() => null);
1801
1812
  }
@@ -1805,7 +1816,7 @@ class xn {
1805
1816
  r.searchParams.set("path", e);
1806
1817
  const s = await fetch(r.toString(), { method: "GET", headers: this.sandboxFsHeaders() });
1807
1818
  if (!s.ok)
1808
- throw new I(s.status, s.statusText, await s.text().catch(() => {
1819
+ throw new w(s.status, s.statusText, await s.text().catch(() => {
1809
1820
  }));
1810
1821
  const o = await s.json(), i = o.data ?? o;
1811
1822
  return {
@@ -1841,6 +1852,36 @@ class xn {
1841
1852
  const o = { src: e, dst: r };
1842
1853
  s?.overwrite && (o.overwrite = "true"), await this.sandboxFsRequest(t, "move", "POST", o);
1843
1854
  }
1855
+ /**
1856
+ * F-021 — watch a sandbox path for changes (`GET fs/watch?path=`, SSE). Each `event: change` frame is one
1857
+ * `SandboxFsWatchEvent`. The backend probes the path first, so a missing path errors as HTTP rather than
1858
+ * as a dead stream. Unsubscribing aborts the request, which ends the sandbox-side watcher.
1859
+ */
1860
+ sandboxFsWatch(t, e) {
1861
+ const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/watch`);
1862
+ return r.searchParams.set("path", e), new S((s) => {
1863
+ const o = new AbortController();
1864
+ return ve(r.toString(), {
1865
+ headers: this.sandboxFsHeaders(),
1866
+ signal: o.signal,
1867
+ openWhenHidden: !0,
1868
+ onopen: async (i) => {
1869
+ if (!i.ok) {
1870
+ const a = await i.text().catch(() => {
1871
+ });
1872
+ s.error(new w(i.status, i.statusText, a)), o.abort();
1873
+ }
1874
+ },
1875
+ onmessage: (i) => {
1876
+ i.event === "change" && s.next(JSON.parse(i.data));
1877
+ },
1878
+ onclose: () => s.complete(),
1879
+ onerror: (i) => {
1880
+ throw s.error(i), o.abort(), i;
1881
+ }
1882
+ }), () => o.abort();
1883
+ });
1884
+ }
1844
1885
  /**
1845
1886
  * 從 botProviderEndpoint 衍生 Blob API endpoint
1846
1887
  */
@@ -1881,7 +1922,7 @@ function un(n, t, e) {
1881
1922
  throw new Error("Random bytes length must be >= 16");
1882
1923
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, sn(r);
1883
1924
  }
1884
- function He(n, t, e) {
1925
+ function Fe(n, t, e) {
1885
1926
  return me.randomUUID && !n ? me.randomUUID() : un(n);
1886
1927
  }
1887
1928
  class v {
@@ -2071,7 +2112,7 @@ class v {
2071
2112
  return s.set(e.messageId, o), new v({ messages: s, pendingConsent: this.pendingConsent });
2072
2113
  }
2073
2114
  onMessageError(t) {
2074
- const e = He(), r = t.fact.runError.error, s = new Map(this.messages);
2115
+ const e = Fe(), r = t.fact.runError.error, s = new Map(this.messages);
2075
2116
  return s.set(e, {
2076
2117
  type: "error",
2077
2118
  eventType: d.ERROR,
@@ -2157,7 +2198,7 @@ function dn(n) {
2157
2198
  function ge(n) {
2158
2199
  return typeof n == "object" && n !== null ? n : void 0;
2159
2200
  }
2160
- function E(n) {
2201
+ function I(n) {
2161
2202
  return typeof n == "string" ? n : void 0;
2162
2203
  }
2163
2204
  function hn(n) {
@@ -2165,18 +2206,18 @@ function hn(n) {
2165
2206
  for (const r of n) {
2166
2207
  const s = r.parameter ?? {}, o = r.sidecar ?? {};
2167
2208
  if (r.toolName === "TaskCreate") {
2168
- const i = ge(o.task), a = E(i?.id);
2209
+ const i = ge(o.task), a = I(i?.id);
2169
2210
  if (!a) continue;
2170
2211
  e.has(a) || t.push(a), e.set(a, {
2171
2212
  id: a,
2172
- subject: E(s.subject) || E(i?.subject) || "",
2173
- activeForm: E(s.activeForm),
2174
- description: E(s.description),
2213
+ subject: I(s.subject) || I(i?.subject) || "",
2214
+ activeForm: I(s.activeForm),
2215
+ description: I(s.description),
2175
2216
  status: e.get(a)?.status ?? "pending"
2176
2217
  // initial status = pending (keep existing on repeat)
2177
2218
  });
2178
2219
  } else if (r.toolName === "TaskUpdate") {
2179
- const i = ge(o.statusChange), a = E(s.taskId) || E(o.taskId), c = E(i?.to) || E(s.status);
2220
+ const i = ge(o.statusChange), a = I(s.taskId) || I(o.taskId), c = I(i?.to) || I(s.status);
2180
2221
  if (!a || !c) continue;
2181
2222
  const u = e.get(a);
2182
2223
  u && e.set(a, { ...u, status: c });
@@ -2463,7 +2504,7 @@ class K {
2463
2504
  }
2464
2505
  }
2465
2506
  subscribe() {
2466
- this.statesSubscription = $t([
2507
+ this.statesSubscription = qt([
2467
2508
  this.isConnecting$,
2468
2509
  this.conversation$,
2469
2510
  this.derivedStores.tasks$,
@@ -2577,7 +2618,7 @@ class K {
2577
2618
  );
2578
2619
  }
2579
2620
  sendMessage(t, e) {
2580
- const r = t.text.trim(), s = t.customMessageId ?? He();
2621
+ const r = t.text.trim(), s = t.customMessageId ?? Fe();
2581
2622
  return this.currentUserMessageId = s, this.lastSentMessageId = s, this.conversation$.next(
2582
2623
  this.conversation$.value.pushMessage({
2583
2624
  type: "user",
@@ -2660,9 +2701,9 @@ export {
2660
2701
  v as Conversation,
2661
2702
  d as EventType,
2662
2703
  $ as FetchSseAction,
2663
- I as HttpError,
2664
- Ke as MessageTemplateType,
2665
- Be as ToolCallConsentResult,
2704
+ w as HttpError,
2705
+ qe as MessageTemplateType,
2706
+ Ke as ToolCallConsentResult,
2666
2707
  bn as conversationToSubagentEvents,
2667
2708
  In as createDerivedStores,
2668
2709
  yn as deriveSubagents,