adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
2,131 lines (2,130 loc) • 3.02 MB
JavaScript
var SS = Object.defineProperty,
vS = Object.defineProperties;
var NS = Object.getOwnPropertyDescriptors;
var Za = Object.getOwnPropertySymbols;
var ZD = Object.prototype.hasOwnProperty,
qD = Object.prototype.propertyIsEnumerable;
var PD = (e, t, A) =>
t in e
? SS(e, t, { enumerable: !0, configurable: !0, writable: !0, value: A })
: (e[t] = A),
R = (e, t) => {
for (var A in (t ||= {})) ZD.call(t, A) && PD(e, A, t[A]);
if (Za) for (var A of Za(t)) qD.call(t, A) && PD(e, A, t[A]);
return e;
},
uA = (e, t) => vS(e, NS(t));
var Dc = (e, t) => {
var A = {};
for (var i in e) ZD.call(e, i) && t.indexOf(i) < 0 && (A[i] = e[i]);
if (e != null && Za)
for (var i of Za(e)) t.indexOf(i) < 0 && qD.call(e, i) && (A[i] = e[i]);
return A;
};
var Ve = (e, t, A) =>
new Promise((i, o) => {
var n = (s) => {
try {
r(A.next(s));
} catch (I) {
o(I);
}
},
g = (s) => {
try {
r(A.throw(s));
} catch (I) {
o(I);
}
},
r = (s) => (s.done ? i(s.value) : Promise.resolve(s.value).then(n, g));
r((A = A.apply(e, t)).next());
});
function yc(e, t) {
return Object.is(e, t);
}
var Ue = null,
qa = !1,
Mc = 1,
lt = Symbol("SIGNAL");
function VA(e) {
let t = Ue;
return (Ue = e), t;
}
function Rc() {
return Ue;
}
var Pg = {
version: 0,
lastCleanEpoch: 0,
dirty: !1,
producerNode: void 0,
producerLastReadVersion: void 0,
producerIndexOfThis: void 0,
nextProducerIndex: 0,
liveConsumerNode: void 0,
liveConsumerIndexOfThis: void 0,
consumerAllowSignalWrites: !1,
consumerIsAlwaysLive: !1,
kind: "unknown",
producerMustRecompute: () => !1,
producerRecomputeValue: () => {},
consumerMarkedDirty: () => {},
consumerOnSignalRead: () => {},
};
function Fs(e) {
if (qa) throw new Error("");
if (Ue === null) return;
Ue.consumerOnSignalRead(e);
let t = Ue.nextProducerIndex++;
if (
(Xa(Ue), t < Ue.producerNode.length && Ue.producerNode[t] !== e && ks(Ue))
) {
let A = Ue.producerNode[t];
ja(A, Ue.producerIndexOfThis[t]);
}
Ue.producerNode[t] !== e &&
((Ue.producerNode[t] = e),
(Ue.producerIndexOfThis[t] = ks(Ue) ? WD(e, Ue, t) : 0)),
(Ue.producerLastReadVersion[t] = e.version);
}
function VD() {
Mc++;
}
function kc(e) {
if (!(ks(e) && !e.dirty) && !(!e.dirty && e.lastCleanEpoch === Mc)) {
if (!e.producerMustRecompute(e) && !za(e)) {
wc(e);
return;
}
e.producerRecomputeValue(e), wc(e);
}
}
function Fc(e) {
if (e.liveConsumerNode === void 0) return;
let t = qa;
qa = !0;
try {
for (let A of e.liveConsumerNode) A.dirty || GS(A);
} finally {
qa = t;
}
}
function bc() {
return Ue?.consumerAllowSignalWrites !== !1;
}
function GS(e) {
(e.dirty = !0), Fc(e), e.consumerMarkedDirty?.(e);
}
function wc(e) {
(e.dirty = !1), (e.lastCleanEpoch = Mc);
}
function bs(e) {
return e && (e.nextProducerIndex = 0), VA(e);
}
function Wa(e, t) {
if (
(VA(t),
!(
!e ||
e.producerNode === void 0 ||
e.producerIndexOfThis === void 0 ||
e.producerLastReadVersion === void 0
))
) {
if (ks(e))
for (let A = e.nextProducerIndex; A < e.producerNode.length; A++)
ja(e.producerNode[A], e.producerIndexOfThis[A]);
for (; e.producerNode.length > e.nextProducerIndex; )
e.producerNode.pop(),
e.producerLastReadVersion.pop(),
e.producerIndexOfThis.pop();
}
}
function za(e) {
Xa(e);
for (let t = 0; t < e.producerNode.length; t++) {
let A = e.producerNode[t],
i = e.producerLastReadVersion[t];
if (i !== A.version || (kc(A), i !== A.version)) return !0;
}
return !1;
}
function Ss(e) {
if ((Xa(e), ks(e)))
for (let t = 0; t < e.producerNode.length; t++)
ja(e.producerNode[t], e.producerIndexOfThis[t]);
(e.producerNode.length =
e.producerLastReadVersion.length =
e.producerIndexOfThis.length =
0),
e.liveConsumerNode &&
(e.liveConsumerNode.length = e.liveConsumerIndexOfThis.length = 0);
}
function WD(e, t, A) {
if ((zD(e), e.liveConsumerNode.length === 0 && jD(e)))
for (let i = 0; i < e.producerNode.length; i++)
e.producerIndexOfThis[i] = WD(e.producerNode[i], e, i);
return e.liveConsumerIndexOfThis.push(A), e.liveConsumerNode.push(t) - 1;
}
function ja(e, t) {
if ((zD(e), e.liveConsumerNode.length === 1 && jD(e)))
for (let i = 0; i < e.producerNode.length; i++)
ja(e.producerNode[i], e.producerIndexOfThis[i]);
let A = e.liveConsumerNode.length - 1;
if (
((e.liveConsumerNode[t] = e.liveConsumerNode[A]),
(e.liveConsumerIndexOfThis[t] = e.liveConsumerIndexOfThis[A]),
e.liveConsumerNode.length--,
e.liveConsumerIndexOfThis.length--,
t < e.liveConsumerNode.length)
) {
let i = e.liveConsumerIndexOfThis[t],
o = e.liveConsumerNode[t];
Xa(o), (o.producerIndexOfThis[i] = t);
}
}
function ks(e) {
return e.consumerIsAlwaysLive || (e?.liveConsumerNode?.length ?? 0) > 0;
}
function Xa(e) {
(e.producerNode ??= []),
(e.producerIndexOfThis ??= []),
(e.producerLastReadVersion ??= []);
}
function zD(e) {
(e.liveConsumerNode ??= []), (e.liveConsumerIndexOfThis ??= []);
}
function jD(e) {
return e.producerNode !== void 0;
}
function $a(e, t) {
let A = Object.create(LS);
(A.computation = e), t !== void 0 && (A.equal = t);
let i = () => {
if ((kc(A), Fs(A), A.value === Va)) throw A.error;
return A.value;
};
return (i[lt] = A), i;
}
var fc = Symbol("UNSET"),
pc = Symbol("COMPUTING"),
Va = Symbol("ERRORED"),
LS = uA(R({}, Pg), {
value: fc,
dirty: !0,
error: null,
equal: yc,
kind: "computed",
producerMustRecompute(e) {
return e.value === fc || e.value === pc;
},
producerRecomputeValue(e) {
if (e.value === pc) throw new Error("Detected cycle in computations.");
let t = e.value;
e.value = pc;
let A = bs(e),
i,
o = !1;
try {
(i = e.computation()),
VA(null),
(o = t !== fc && t !== Va && i !== Va && e.equal(t, i));
} catch (n) {
(i = Va), (e.error = n);
} finally {
Wa(e, A);
}
if (o) {
e.value = t;
return;
}
(e.value = i), e.version++;
},
});
function _S() {
throw new Error();
}
var XD = _S;
function $D(e) {
XD(e);
}
function Sc(e) {
XD = e;
}
var KS = null;
function vc(e, t) {
let A = Object.create(AC);
(A.value = e), t !== void 0 && (A.equal = t);
let i = () => (Fs(A), A.value);
return (i[lt] = A), i;
}
function vs(e, t) {
bc() || $D(e), e.equal(e.value, t) || ((e.value = t), US(e));
}
function Nc(e, t) {
bc() || $D(e), vs(e, t(e.value));
}
var AC = uA(R({}, Pg), { equal: yc, value: void 0, kind: "signal" });
function US(e) {
e.version++, VD(), Fc(e), KS?.();
}
function Gc(e) {
let t = VA(null);
try {
return e();
} finally {
VA(t);
}
}
var Lc;
function Ns() {
return Lc;
}
function po(e) {
let t = Lc;
return (Lc = e), t;
}
var eC = Symbol("NotFound");
function yA(e) {
return typeof e == "function";
}
function Zg(e) {
let A = e((i) => {
Error.call(i), (i.stack = new Error().stack);
});
return (
(A.prototype = Object.create(Error.prototype)),
(A.prototype.constructor = A),
A
);
}
var tC = Zg(
(e) =>
function (A) {
e(this),
(this.message = A
? `${A.length} errors occurred during unsubscription:
${A.map((i, o) => `${o + 1}) ${i.toString()}`).join(`
`)}`
: ""),
(this.name = "UnsubscriptionError"),
(this.errors = A);
}
);
function Ln(e, t) {
if (e) {
let A = e.indexOf(t);
0 <= A && e.splice(A, 1);
}
}
var NA = class e {
constructor(t) {
(this.initialTeardown = t),
(this.closed = !1),
(this._parentage = null),
(this._finalizers = null);
}
unsubscribe() {
let t;
if (!this.closed) {
this.closed = !0;
let { _parentage: A } = this;
if (A)
if (((this._parentage = null), Array.isArray(A)))
for (let n of A) n.remove(this);
else A.remove(this);
let { initialTeardown: i } = this;
if (yA(i))
try {
i();
} catch (n) {
t = n instanceof tC ? n.errors : [n];
}
let { _finalizers: o } = this;
if (o) {
this._finalizers = null;
for (let n of o)
try {
Af(n);
} catch (g) {
(t = t ?? []),
g instanceof tC ? (t = [...t, ...g.errors]) : t.push(g);
}
}
if (t) throw new tC(t);
}
}
add(t) {
var A;
if (t && t !== this)
if (this.closed) Af(t);
else {
if (t instanceof e) {
if (t.closed || t._hasParent(this)) return;
t._addParent(this);
}
(this._finalizers =
(A = this._finalizers) !== null && A !== void 0 ? A : []).push(t);
}
}
_hasParent(t) {
let { _parentage: A } = this;
return A === t || (Array.isArray(A) && A.includes(t));
}
_addParent(t) {
let { _parentage: A } = this;
this._parentage = Array.isArray(A) ? (A.push(t), A) : A ? [A, t] : t;
}
_removeParent(t) {
let { _parentage: A } = this;
A === t ? (this._parentage = null) : Array.isArray(A) && Ln(A, t);
}
remove(t) {
let { _finalizers: A } = this;
A && Ln(A, t), t instanceof e && t._removeParent(this);
}
};
NA.EMPTY = (() => {
let e = new NA();
return (e.closed = !0), e;
})();
var _c = NA.EMPTY;
function iC(e) {
return (
e instanceof NA ||
(e && "closed" in e && yA(e.remove) && yA(e.add) && yA(e.unsubscribe))
);
}
function Af(e) {
yA(e) ? e() : e.unsubscribe();
}
var Ci = {
onUnhandledError: null,
onStoppedNotification: null,
Promise: void 0,
useDeprecatedSynchronousErrorHandling: !1,
useDeprecatedNextContext: !1,
};
var qg = {
setTimeout(e, t, ...A) {
let { delegate: i } = qg;
return i?.setTimeout ? i.setTimeout(e, t, ...A) : setTimeout(e, t, ...A);
},
clearTimeout(e) {
let { delegate: t } = qg;
return (t?.clearTimeout || clearTimeout)(e);
},
delegate: void 0,
};
function oC(e) {
qg.setTimeout(() => {
let { onUnhandledError: t } = Ci;
if (t) t(e);
else throw e;
});
}
function Gs() {}
var ef = Kc("C", void 0, void 0);
function tf(e) {
return Kc("E", void 0, e);
}
function of(e) {
return Kc("N", e, void 0);
}
function Kc(e, t, A) {
return { kind: e, value: t, error: A };
}
var _n = null;
function Vg(e) {
if (Ci.useDeprecatedSynchronousErrorHandling) {
let t = !_n;
if ((t && (_n = { errorThrown: !1, error: null }), e(), t)) {
let { errorThrown: A, error: i } = _n;
if (((_n = null), A)) throw i;
}
} else e();
}
function nf(e) {
Ci.useDeprecatedSynchronousErrorHandling &&
_n &&
((_n.errorThrown = !0), (_n.error = e));
}
var wo = class extends NA {
constructor(t) {
super(),
(this.isStopped = !1),
t
? ((this.destination = t), iC(t) && t.add(this))
: (this.destination = OS);
}
static create(t, A, i) {
return new yo(t, A, i);
}
next(t) {
this.isStopped ? xc(of(t), this) : this._next(t);
}
error(t) {
this.isStopped
? xc(tf(t), this)
: ((this.isStopped = !0), this._error(t));
}
complete() {
this.isStopped ? xc(ef, this) : ((this.isStopped = !0), this._complete());
}
unsubscribe() {
this.closed ||
((this.isStopped = !0), super.unsubscribe(), (this.destination = null));
}
_next(t) {
this.destination.next(t);
}
_error(t) {
try {
this.destination.error(t);
} finally {
this.unsubscribe();
}
}
_complete() {
try {
this.destination.complete();
} finally {
this.unsubscribe();
}
}
},
HS = Function.prototype.bind;
function Uc(e, t) {
return HS.call(e, t);
}
var Yc = class {
constructor(t) {
this.partialObserver = t;
}
next(t) {
let { partialObserver: A } = this;
if (A.next)
try {
A.next(t);
} catch (i) {
nC(i);
}
}
error(t) {
let { partialObserver: A } = this;
if (A.error)
try {
A.error(t);
} catch (i) {
nC(i);
}
else nC(t);
}
complete() {
let { partialObserver: t } = this;
if (t.complete)
try {
t.complete();
} catch (A) {
nC(A);
}
}
},
yo = class extends wo {
constructor(t, A, i) {
super();
let o;
if (yA(t) || !t)
o = { next: t ?? void 0, error: A ?? void 0, complete: i ?? void 0 };
else {
let n;
this && Ci.useDeprecatedNextContext
? ((n = Object.create(t)),
(n.unsubscribe = () => this.unsubscribe()),
(o = {
next: t.next && Uc(t.next, n),
error: t.error && Uc(t.error, n),
complete: t.complete && Uc(t.complete, n),
}))
: (o = t);
}
this.destination = new Yc(o);
}
};
function nC(e) {
Ci.useDeprecatedSynchronousErrorHandling ? nf(e) : oC(e);
}
function TS(e) {
throw e;
}
function xc(e, t) {
let { onStoppedNotification: A } = Ci;
A && qg.setTimeout(() => A(e, t));
}
var OS = { closed: !0, next: Gs, error: TS, complete: Gs };
var Wg = (typeof Symbol == "function" && Symbol.observable) || "@@observable";
function at(e) {
return e;
}
function Jc(...e) {
return Hc(e);
}
function Hc(e) {
return e.length === 0
? at
: e.length === 1
? e[0]
: function (A) {
return e.reduce((i, o) => o(i), A);
};
}
var lA = (() => {
class e {
constructor(A) {
A && (this._subscribe = A);
}
lift(A) {
let i = new e();
return (i.source = this), (i.operator = A), i;
}
subscribe(A, i, o) {
let n = ZS(A) ? A : new yo(A, i, o);
return (
Vg(() => {
let { operator: g, source: r } = this;
n.add(
g ? g.call(n, r) : r ? this._subscribe(n) : this._trySubscribe(n)
);
}),
n
);
}
_trySubscribe(A) {
try {
return this._subscribe(A);
} catch (i) {
A.error(i);
}
}
forEach(A, i) {
return (
(i = gf(i)),
new i((o, n) => {
let g = new yo({
next: (r) => {
try {
A(r);
} catch (s) {
n(s), g.unsubscribe();
}
},
error: n,
complete: o,
});
this.subscribe(g);
})
);
}
_subscribe(A) {
var i;
return (i = this.source) === null || i === void 0
? void 0
: i.subscribe(A);
}
[Wg]() {
return this;
}
pipe(...A) {
return Hc(A)(this);
}
toPromise(A) {
return (
(A = gf(A)),
new A((i, o) => {
let n;
this.subscribe(
(g) => (n = g),
(g) => o(g),
() => i(n)
);
})
);
}
}
return (e.create = (t) => new e(t)), e;
})();
function gf(e) {
var t;
return (t = e ?? Ci.Promise) !== null && t !== void 0 ? t : Promise;
}
function PS(e) {
return e && yA(e.next) && yA(e.error) && yA(e.complete);
}
function ZS(e) {
return (e && e instanceof wo) || (PS(e) && iC(e));
}
function Tc(e) {
return yA(e?.lift);
}
function GA(e) {
return (t) => {
if (Tc(t))
return t.lift(function (A) {
try {
return e(A, this);
} catch (i) {
this.error(i);
}
});
throw new TypeError("Unable to lift unknown Observable type");
};
}
function SA(e, t, A, i, o) {
return new Oc(e, t, A, i, o);
}
var Oc = class extends wo {
constructor(t, A, i, o, n, g) {
super(t),
(this.onFinalize = n),
(this.shouldUnsubscribe = g),
(this._next = A
? function (r) {
try {
A(r);
} catch (s) {
t.error(s);
}
}
: super._next),
(this._error = o
? function (r) {
try {
o(r);
} catch (s) {
t.error(s);
} finally {
this.unsubscribe();
}
}
: super._error),
(this._complete = i
? function () {
try {
i();
} catch (r) {
t.error(r);
} finally {
this.unsubscribe();
}
}
: super._complete);
}
unsubscribe() {
var t;
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
let { closed: A } = this;
super.unsubscribe(),
!A && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
}
}
};
function zg() {
return GA((e, t) => {
let A = null;
e._refCount++;
let i = SA(t, void 0, void 0, void 0, () => {
if (!e || e._refCount <= 0 || 0 < --e._refCount) {
A = null;
return;
}
let o = e._connection,
n = A;
(A = null), o && (!n || o === n) && o.unsubscribe(), t.unsubscribe();
});
e.subscribe(i), i.closed || (A = e.connect());
});
}
var Wo = class extends lA {
constructor(t, A) {
super(),
(this.source = t),
(this.subjectFactory = A),
(this._subject = null),
(this._refCount = 0),
(this._connection = null),
Tc(t) && (this.lift = t.lift);
}
_subscribe(t) {
return this.getSubject().subscribe(t);
}
getSubject() {
let t = this._subject;
return (
(!t || t.isStopped) && (this._subject = this.subjectFactory()),
this._subject
);
}
_teardown() {
this._refCount = 0;
let { _connection: t } = this;
(this._subject = this._connection = null), t?.unsubscribe();
}
connect() {
let t = this._connection;
if (!t) {
t = this._connection = new NA();
let A = this.getSubject();
t.add(
this.source.subscribe(
SA(
A,
void 0,
() => {
this._teardown(), A.complete();
},
(i) => {
this._teardown(), A.error(i);
},
() => this._teardown()
)
)
),
t.closed && ((this._connection = null), (t = NA.EMPTY));
}
return t;
}
refCount() {
return zg()(this);
}
};
var rf = Zg(
(e) =>
function () {
e(this),
(this.name = "ObjectUnsubscribedError"),
(this.message = "object unsubscribed");
}
);
var _ = (() => {
class e extends lA {
constructor() {
super(),
(this.closed = !1),
(this.currentObservers = null),
(this.observers = []),
(this.isStopped = !1),
(this.hasError = !1),
(this.thrownError = null);
}
lift(A) {
let i = new jg(this, this);
return (i.operator = A), i;
}
_throwIfClosed() {
if (this.closed) throw new rf();
}
next(A) {
Vg(() => {
if ((this._throwIfClosed(), !this.isStopped)) {
this.currentObservers ||
(this.currentObservers = Array.from(this.observers));
for (let i of this.currentObservers) i.next(A);
}
});
}
error(A) {
Vg(() => {
if ((this._throwIfClosed(), !this.isStopped)) {
(this.hasError = this.isStopped = !0), (this.thrownError = A);
let { observers: i } = this;
for (; i.length; ) i.shift().error(A);
}
});
}
complete() {
Vg(() => {
if ((this._throwIfClosed(), !this.isStopped)) {
this.isStopped = !0;
let { observers: A } = this;
for (; A.length; ) A.shift().complete();
}
});
}
unsubscribe() {
(this.isStopped = this.closed = !0),
(this.observers = this.currentObservers = null);
}
get observed() {
var A;
return (
((A = this.observers) === null || A === void 0 ? void 0 : A.length) >
0
);
}
_trySubscribe(A) {
return this._throwIfClosed(), super._trySubscribe(A);
}
_subscribe(A) {
return (
this._throwIfClosed(),
this._checkFinalizedStatuses(A),
this._innerSubscribe(A)
);
}
_innerSubscribe(A) {
let { hasError: i, isStopped: o, observers: n } = this;
return i || o
? _c
: ((this.currentObservers = null),
n.push(A),
new NA(() => {
(this.currentObservers = null), Ln(n, A);
}));
}
_checkFinalizedStatuses(A) {
let { hasError: i, thrownError: o, isStopped: n } = this;
i ? A.error(o) : n && A.complete();
}
asObservable() {
let A = new lA();
return (A.source = this), A;
}
}
return (e.create = (t, A) => new jg(t, A)), e;
})(),
jg = class extends _ {
constructor(t, A) {
super(), (this.destination = t), (this.source = A);
}
next(t) {
var A, i;
(i =
(A = this.destination) === null || A === void 0 ? void 0 : A.next) ===
null ||
i === void 0 ||
i.call(A, t);
}
error(t) {
var A, i;
(i =
(A = this.destination) === null || A === void 0 ? void 0 : A.error) ===
null ||
i === void 0 ||
i.call(A, t);
}
complete() {
var t, A;
(A =
(t = this.destination) === null || t === void 0
? void 0
: t.complete) === null ||
A === void 0 ||
A.call(t);
}
_subscribe(t) {
var A, i;
return (i =
(A = this.source) === null || A === void 0
? void 0
: A.subscribe(t)) !== null && i !== void 0
? i
: _c;
}
};
var te = class extends _ {
constructor(t) {
super(), (this._value = t);
}
get value() {
return this.getValue();
}
_subscribe(t) {
let A = super._subscribe(t);
return !A.closed && t.next(this._value), A;
}
getValue() {
let { hasError: t, thrownError: A, _value: i } = this;
if (t) throw A;
return this._throwIfClosed(), i;
}
next(t) {
super.next((this._value = t));
}
};
var Ls = {
now() {
return (Ls.delegate || Date).now();
},
delegate: void 0,
};
var Bi = class extends _ {
constructor(t = 1 / 0, A = 1 / 0, i = Ls) {
super(),
(this._bufferSize = t),
(this._windowTime = A),
(this._timestampProvider = i),
(this._buffer = []),
(this._infiniteTimeWindow = !0),
(this._infiniteTimeWindow = A === 1 / 0),
(this._bufferSize = Math.max(1, t)),
(this._windowTime = Math.max(1, A));
}
next(t) {
let {
isStopped: A,
_buffer: i,
_infiniteTimeWindow: o,
_timestampProvider: n,
_windowTime: g,
} = this;
A || (i.push(t), !o && i.push(n.now() + g)),
this._trimBuffer(),
super.next(t);
}
_subscribe(t) {
this._throwIfClosed(), this._trimBuffer();
let A = this._innerSubscribe(t),
{ _infiniteTimeWindow: i, _buffer: o } = this,
n = o.slice();
for (let g = 0; g < n.length && !t.closed; g += i ? 1 : 2) t.next(n[g]);
return this._checkFinalizedStatuses(t), A;
}
_trimBuffer() {
let {
_bufferSize: t,
_timestampProvider: A,
_buffer: i,
_infiniteTimeWindow: o,
} = this,
n = (o ? 1 : 2) * t;
if ((t < 1 / 0 && n < i.length && i.splice(0, i.length - n), !o)) {
let g = A.now(),
r = 0;
for (let s = 1; s < i.length && i[s] <= g; s += 2) r = s;
r && i.splice(0, r + 1);
}
}
};
var gC = class extends NA {
constructor(t, A) {
super();
}
schedule(t, A = 0) {
return this;
}
};
var _s = {
setInterval(e, t, ...A) {
let { delegate: i } = _s;
return i?.setInterval ? i.setInterval(e, t, ...A) : setInterval(e, t, ...A);
},
clearInterval(e) {
let { delegate: t } = _s;
return (t?.clearInterval || clearInterval)(e);
},
delegate: void 0,
};
var rC = class extends gC {
constructor(t, A) {
super(t, A), (this.scheduler = t), (this.work = A), (this.pending = !1);
}
schedule(t, A = 0) {
var i;
if (this.closed) return this;
this.state = t;
let o = this.id,
n = this.scheduler;
return (
o != null && (this.id = this.recycleAsyncId(n, o, A)),
(this.pending = !0),
(this.delay = A),
(this.id =
(i = this.id) !== null && i !== void 0
? i
: this.requestAsyncId(n, this.id, A)),
this
);
}
requestAsyncId(t, A, i = 0) {
return _s.setInterval(t.flush.bind(t, this), i);
}
recycleAsyncId(t, A, i = 0) {
if (i != null && this.delay === i && this.pending === !1) return A;
A != null && _s.clearInterval(A);
}
execute(t, A) {
if (this.closed) return new Error("executing a cancelled action");
this.pending = !1;
let i = this._execute(t, A);
if (i) return i;
this.pending === !1 &&
this.id != null &&
(this.id = this.recycleAsyncId(this.scheduler, this.id, null));
}
_execute(t, A) {
let i = !1,
o;
try {
this.work(t);
} catch (n) {
(i = !0), (o = n || new Error("Scheduled action threw falsy error"));
}
if (i) return this.unsubscribe(), o;
}
unsubscribe() {
if (!this.closed) {
let { id: t, scheduler: A } = this,
{ actions: i } = A;
(this.work = this.state = this.scheduler = null),
(this.pending = !1),
Ln(i, this),
t != null && (this.id = this.recycleAsyncId(A, t, null)),
(this.delay = null),
super.unsubscribe();
}
}
};
var Xg = class e {
constructor(t, A = e.now) {
(this.schedulerActionCtor = t), (this.now = A);
}
schedule(t, A = 0, i) {
return new this.schedulerActionCtor(this, t).schedule(i, A);
}
};
Xg.now = Ls.now;
var sC = class extends Xg {
constructor(t, A = Xg.now) {
super(t, A), (this.actions = []), (this._active = !1);
}
flush(t) {
let { actions: A } = this;
if (this._active) {
A.push(t);
return;
}
let i;
this._active = !0;
do if ((i = t.execute(t.state, t.delay))) break;
while ((t = A.shift()));
if (((this._active = !1), i)) {
for (; (t = A.shift()); ) t.unsubscribe();
throw i;
}
}
};
var Ks = new sC(rC),
sf = Ks;
var Le = new lA((e) => e.complete());
function IC(e) {
return e && yA(e.schedule);
}
function Pc(e) {
return e[e.length - 1];
}
function aC(e) {
return yA(Pc(e)) ? e.pop() : void 0;
}
function Ji(e) {
return IC(Pc(e)) ? e.pop() : void 0;
}
function If(e, t) {
return typeof Pc(e) == "number" ? e.pop() : t;
}
function Cf(e, t, A, i) {
function o(n) {
return n instanceof A
? n
: new A(function (g) {
g(n);
});
}
return new (A || (A = Promise))(function (n, g) {
function r(Q) {
try {
I(i.next(Q));
} catch (c) {
g(c);
}
}
function s(Q) {
try {
I(i.throw(Q));
} catch (c) {
g(c);
}
}
function I(Q) {
Q.done ? n(Q.value) : o(Q.value).then(r, s);
}
I((i = i.apply(e, t || [])).next());
});
}
function af(e) {
var t = typeof Symbol == "function" && Symbol.iterator,
A = t && e[t],
i = 0;
if (A) return A.call(e);
if (e && typeof e.length == "number")
return {
next: function () {
return (
e && i >= e.length && (e = void 0), { value: e && e[i++], done: !e }
);
},
};
throw new TypeError(
t ? "Object is not iterable." : "Symbol.iterator is not defined."
);
}
function Kn(e) {
return this instanceof Kn ? ((this.v = e), this) : new Kn(e);
}
function Bf(e, t, A) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var i = A.apply(e, t || []),
o,
n = [];
return (
(o = Object.create(
(typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype
)),
r("next"),
r("throw"),
r("return", g),
(o[Symbol.asyncIterator] = function () {
return this;
}),
o
);
function g(h) {
return function (p) {
return Promise.resolve(p).then(h, c);
};
}
function r(h, p) {
i[h] &&
((o[h] = function (y) {
return new Promise(function (L, q) {
n.push([h, y, L, q]) > 1 || s(h, y);
});
}),
p && (o[h] = p(o[h])));
}
function s(h, p) {
try {
I(i[h](p));
} catch (y) {
D(n[0][3], y);
}
}
function I(h) {
h.value instanceof Kn
? Promise.resolve(h.value.v).then(Q, c)
: D(n[0][2], h);
}
function Q(h) {
s("next", h);
}
function c(h) {
s("throw", h);
}
function D(h, p) {
h(p), n.shift(), n.length && s(n[0][0], n[0][1]);
}
}
function Qf(e) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var t = e[Symbol.asyncIterator],
A;
return t
? t.call(e)
: ((e = typeof af == "function" ? af(e) : e[Symbol.iterator]()),
(A = {}),
i("next"),
i("throw"),
i("return"),
(A[Symbol.asyncIterator] = function () {
return this;
}),
A);
function i(n) {
A[n] =
e[n] &&
function (g) {
return new Promise(function (r, s) {
(g = e[n](g)), o(r, s, g.done, g.value);
});
};
}
function o(n, g, r, s) {
Promise.resolve(s).then(function (I) {
n({ value: I, done: r });
}, g);
}
}
var $g = (e) => e && typeof e.length == "number" && typeof e != "function";
function CC(e) {
return yA(e?.then);
}
function BC(e) {
return yA(e[Wg]);
}
function QC(e) {
return Symbol.asyncIterator && yA(e?.[Symbol.asyncIterator]);
}
function EC(e) {
return new TypeError(
`You provided ${e !== null && typeof e == "object" ? "an invalid object" : `'${e}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`
);
}
function qS() {
return typeof Symbol != "function" || !Symbol.iterator
? "@@iterator"
: Symbol.iterator;
}
var cC = qS();
function lC(e) {
return yA(e?.[cC]);
}
function dC(e) {
return Bf(this, arguments, function* () {
let A = e.getReader();
try {
for (;;) {
let { value: i, done: o } = yield Kn(A.read());
if (o) return yield Kn(void 0);
yield yield Kn(i);
}
} finally {
A.releaseLock();
}
});
}
function hC(e) {
return yA(e?.getReader);
}
function ne(e) {
if (e instanceof lA) return e;
if (e != null) {
if (BC(e)) return VS(e);
if ($g(e)) return WS(e);
if (CC(e)) return zS(e);
if (QC(e)) return Ef(e);
if (lC(e)) return jS(e);
if (hC(e)) return XS(e);
}
throw EC(e);
}
function VS(e) {
return new lA((t) => {
let A = e[Wg]();
if (yA(A.subscribe)) return A.subscribe(t);
throw new TypeError(
"Provided object does not correctly implement Symbol.observable"
);
});
}
function WS(e) {
return new lA((t) => {
for (let A = 0; A < e.length && !t.closed; A++) t.next(e[A]);
t.complete();
});
}
function zS(e) {
return new lA((t) => {
e.then(
(A) => {
t.closed || (t.next(A), t.complete());
},
(A) => t.error(A)
).then(null, oC);
});
}
function jS(e) {
return new lA((t) => {
for (let A of e) if ((t.next(A), t.closed)) return;
t.complete();
});
}
function Ef(e) {
return new lA((t) => {
$S(e, t).catch((A) => t.error(A));
});
}
function XS(e) {
return Ef(dC(e));
}
function $S(e, t) {
var A, i, o, n;
return Cf(this, void 0, void 0, function* () {
try {
for (A = Qf(e); (i = yield A.next()), !i.done; ) {
let g = i.value;
if ((t.next(g), t.closed)) return;
}
} catch (g) {
o = { error: g };
} finally {
try {
i && !i.done && (n = A.return) && (yield n.call(A));
} finally {
if (o) throw o.error;
}
}
t.complete();
});
}
function dt(e, t, A, i = 0, o = !1) {
let n = t.schedule(function () {
A(), o ? e.add(this.schedule(null, i)) : this.unsubscribe();
}, i);
if ((e.add(n), !o)) return n;
}
function uC(e, t = 0) {
return GA((A, i) => {
A.subscribe(
SA(
i,
(o) => dt(i, e, () => i.next(o), t),
() => dt(i, e, () => i.complete(), t),
(o) => dt(i, e, () => i.error(o), t)
)
);
});
}
function mC(e, t = 0) {
return GA((A, i) => {
i.add(e.schedule(() => A.subscribe(i), t));
});
}
function cf(e, t) {
return ne(e).pipe(mC(t), uC(t));
}
function lf(e, t) {
return ne(e).pipe(mC(t), uC(t));
}
function df(e, t) {
return new lA((A) => {
let i = 0;
return t.schedule(function () {
i === e.length
? A.complete()
: (A.next(e[i++]), A.closed || this.schedule());
});
});
}
function hf(e, t) {
return new lA((A) => {
let i;
return (
dt(A, t, () => {
(i = e[cC]()),
dt(
A,
t,
() => {
let o, n;
try {
({ value: o, done: n } = i.next());
} catch (g) {
A.error(g);
return;
}
n ? A.complete() : A.next(o);
},
0,
!0
);
}),
() => yA(i?.return) && i.return()
);
});
}
function DC(e, t) {
if (!e) throw new Error("Iterable cannot be null");
return new lA((A) => {
dt(A, t, () => {
let i = e[Symbol.asyncIterator]();
dt(
A,
t,
() => {
i.next().then((o) => {
o.done ? A.complete() : A.next(o.value);
});
},
0,
!0
);
});
});
}
function uf(e, t) {
return DC(dC(e), t);
}
function mf(e, t) {
if (e != null) {
if (BC(e)) return cf(e, t);
if ($g(e)) return df(e, t);
if (CC(e)) return lf(e, t);
if (QC(e)) return DC(e, t);
if (lC(e)) return hf(e, t);
if (hC(e)) return uf(e, t);
}
throw EC(e);
}
function se(e, t) {
return t ? mf(e, t) : ne(e);
}
function iA(...e) {
let t = Ji(e);
return se(e, t);
}
function zo(e, t) {
let A = yA(e) ? e : () => e,
i = (o) => o.error(A());
return new lA(t ? (o) => t.schedule(i, 0, o) : i);
}
function jo(e) {
return !!e && (e instanceof lA || (yA(e.lift) && yA(e.subscribe)));
}
var Mo = Zg(
(e) =>
function () {
e(this),
(this.name = "EmptyError"),
(this.message = "no elements in sequence");
}
);
function Df(e) {
return e instanceof Date && !isNaN(e);
}
function nA(e, t) {
return GA((A, i) => {
let o = 0;
A.subscribe(
SA(i, (n) => {
i.next(e.call(t, n, o++));
})
);
});
}
var { isArray: Av } = Array;
function ev(e, t) {
return Av(t) ? e(...t) : e(t);
}
function Ar(e) {
return nA((t) => ev(e, t));
}
var { isArray: tv } = Array,
{ getPrototypeOf: iv, prototype: ov, keys: nv } = Object;
function fC(e) {
if (e.length === 1) {
let t = e[0];
if (tv(t)) return { args: t, keys: null };
if (gv(t)) {
let A = nv(t);
return { args: A.map((i) => t[i]), keys: A };
}
}
return { args: e, keys: null };
}
function gv(e) {
return e && typeof e == "object" && iv(e) === ov;
}
function pC(e, t) {
return e.reduce((A, i, o) => ((A[i] = t[o]), A), {});
}
function Qi(...e) {
let t = Ji(e),
A = aC(e),
{ args: i, keys: o } = fC(e);
if (i.length === 0) return se([], t);
let n = new lA(rv(i, t, o ? (g) => pC(o, g) : at));
return A ? n.pipe(Ar(A)) : n;
}
function rv(e, t, A = at) {
return (i) => {
ff(
t,
() => {
let { length: o } = e,
n = new Array(o),
g = o,
r = o;
for (let s = 0; s < o; s++)
ff(
t,
() => {
let I = se(e[s], t),
Q = !1;
I.subscribe(
SA(
i,
(c) => {
(n[s] = c), Q || ((Q = !0), r--), r || i.next(A(n.slice()));
},
() => {
--g || i.complete();
}
)
);
},
i
);
},
i
);
};
}
function ff(e, t, A) {
e ? dt(A, e, t) : t();
}
function pf(e, t, A, i, o, n, g, r) {
let s = [],
I = 0,
Q = 0,
c = !1,
D = () => {
c && !s.length && !I && t.complete();
},
h = (y) => (I < i ? p(y) : s.push(y)),
p = (y) => {
n && t.next(y), I++;
let L = !1;
ne(A(y, Q++)).subscribe(
SA(
t,
(q) => {
o?.(q), n ? h(q) : t.next(q);
},
() => {
L = !0;
},
void 0,
() => {
if (L)
try {
for (I--; s.length && I < i; ) {
let q = s.shift();
g ? dt(t, g, () => p(q)) : p(q);
}
D();
} catch (q) {
t.error(q);
}
}
)
);
};
return (
e.subscribe(
SA(t, h, () => {
(c = !0), D();
})
),
() => {
r?.();
}
);
}
function Re(e, t, A = 1 / 0) {
return yA(t)
? Re((i, o) => nA((n, g) => t(i, n, o, g))(ne(e(i, o))), A)
: (typeof t == "number" && (A = t), GA((i, o) => pf(i, o, e, A)));
}
function Xo(e = 1 / 0) {
return Re(at, e);
}
function wf() {
return Xo(1);
}
function $o(...e) {
return wf()(se(e, Ji(e)));
}
function Hi(e) {
return new lA((t) => {
ne(e()).subscribe(t);
});
}
function Us(...e) {
let t = aC(e),
{ args: A, keys: i } = fC(e),
o = new lA((n) => {
let { length: g } = A;
if (!g) {
n.complete();
return;
}
let r = new Array(g),
s = g,
I = g;
for (let Q = 0; Q < g; Q++) {
let c = !1;
ne(A[Q]).subscribe(
SA(
n,
(D) => {
c || ((c = !0), I--), (r[Q] = D);
},
() => s--,
void 0,
() => {
(!s || !c) && (I || n.next(i ? pC(i, r) : r), n.complete());
}
)
);
}
});
return t ? o.pipe(Ar(t)) : o;
}
var sv = ["addListener", "removeListener"],
Iv = ["addEventListener", "removeEventListener"],
av = ["on", "off"];
function xs(e, t, A, i) {
if ((yA(A) && ((i = A), (A = void 0)), i)) return xs(e, t, A).pipe(Ar(i));
let [o, n] = Qv(e)
? Iv.map((g) => (r) => e[g](t, r, A))
: Cv(e)
? sv.map(yf(e, t))
: Bv(e)
? av.map(yf(e, t))
: [];
if (!o && $g(e)) return Re((g) => xs(g, t, A))(ne(e));
if (!o) throw new TypeError("Invalid event target");
return new lA((g) => {
let r = (...s) => g.next(1 < s.length ? s : s[0]);
return o(r), () => n(r);
});
}
function yf(e, t) {
return (A) => (i) => e[A](t, i);
}
function Cv(e) {
return yA(e.addListener) && yA(e.removeListener);
}
function Bv(e) {
return yA(e.on) && yA(e.off);
}
function Qv(e) {
return yA(e.addEventListener) && yA(e.removeEventListener);
}
function Un(e = 0, t, A = sf) {
let i = -1;
return (
t != null && (IC(t) ? (A = t) : (i = t)),
new lA((o) => {
let n = Df(e) ? +e - A.now() : e;
n < 0 && (n = 0);
let g = 0;
return A.schedule(function () {
o.closed ||
(o.next(g++), 0 <= i ? this.schedule(void 0, i) : o.complete());
}, n);
})
);
}
function Ce(...e) {
let t = Ji(e),
A = If(e, 1 / 0),
i = e;
return i.length ? (i.length === 1 ? ne(i[0]) : Xo(A)(se(i, t))) : Le;
}
function kA(e, t) {
return GA((A, i) => {
let o = 0;
A.subscribe(SA(i, (n) => e.call(t, n, o++) && i.next(n)));
});
}
function Mf(e) {
return GA((t, A) => {
let i = !1,
o = null,
n = null,
g = !1,
r = () => {
if ((n?.unsubscribe(), (n = null), i)) {
i = !1;
let I = o;
(o = null), A.next(I);
}
g && A.complete();
},
s = () => {
(n = null), g && A.complete();
};
t.subscribe(
SA(
A,
(I) => {
(i = !0), (o = I), n || ne(e(I)).subscribe((n = SA(A, r, s)));
},
() => {
(g = !0), (!i || !n || n.closed) && A.complete();
}
)
);
});
}
function wC(e, t = Ks) {
return Mf(() => Un(e, t));
}
function ht(e) {
return GA((t, A) => {
let i = null,
o = !1,
n;
(i = t.subscribe(
SA(A, void 0, void 0, (g) => {
(n = ne(e(g, ht(e)(t)))),
i ? (i.unsubscribe(), (i = null), n.subscribe(A)) : (o = !0);
})
)),
o && (i.unsubscribe(), (i = null), n.subscribe(A));
});
}
function Rf(e, t, A, i, o) {
return (n, g) => {
let r = A,
s = t,
I = 0;
n.subscribe(
SA(
g,
(Q) => {
let c = I++;
(s = r ? e(s, Q, c) : ((r = !0), Q)), i && g.next(s);
},
o &&
(() => {
r && g.next(s), g.complete();
})
)
);
};
}
function Ti(e, t) {
return yA(t) ? Re(e, t, 1) : Re(e, 1);
}
function Ei(e, t = Ks) {
return GA((A, i) => {
let o = null,
n = null,
g = null,
r = () => {
if (o) {
o.unsubscribe(), (o = null);
let I = n;
(n = null), i.next(I);
}
};
function s() {
let I = g + e,
Q = t.now();
if (Q < I) {
(o = this.schedule(void 0, I - Q)), i.add(o);
return;
}
r();
}
A.subscribe(
SA(
i,
(I) => {
(n = I), (g = t.now()), o || ((o = t.schedule(s, e)), i.add(o));
},
() => {
r(), i.complete();
},
void 0,
() => {
n = o = null;
}
)
);
});
}
function An(e) {
return GA((t, A) => {
let i = !1;
t.subscribe(
SA(
A,
(o) => {
(i = !0), A.next(o);
},
() => {
i || A.next(e), A.complete();
}
)
);
});
}
function ue(e) {
return e <= 0
? () => Le
: GA((t, A) => {
let i = 0;
t.subscribe(
SA(A, (o) => {
++i <= e && (A.next(o), e <= i && A.complete());
})
);
});
}
function er(e) {
return nA(() => e);
}
function ci(e, t = at) {
return (
(e = e ?? Ev),
GA((A, i) => {
let o,
n = !0;
A.subscribe(
SA(i, (g) => {
let r = t(g);
(n || !e(o, r)) && ((n = !1), (o = r), i.next(g));
})
);
})
);
}
function Ev(e, t) {
return e === t;
}
function yC(e = cv) {
return GA((t, A) => {
let i = !1;
t.subscribe(
SA(
A,
(o) => {
(i = !0), A.next(o);
},
() => (i ? A.complete() : A.error(e()))
)
);
});
}
function cv() {
return new Mo();
}
function Oi(e) {
return GA((t, A) => {
try {
t.subscribe(A);
} finally {
A.add(e);
}
});
}
function Pi(e, t) {
let A = arguments.length >= 2;
return (i) =>
i.pipe(
e ? kA((o, n) => e(o, n, i)) : at,
ue(1),
A ? An(t) : yC(() => new Mo())
);
}
function tr(e) {
return e <= 0
? () => Le
: GA((t, A) => {
let i = [];
t.subscribe(
SA(
A,
(o) => {
i.push(o), e < i.length && i.shift();
},
() => {
for (let o of i) A.next(o);
A.complete();
},
void 0,
() => {
i = null;
}
)
);
});
}
function Zc(e, t) {
let A = arguments.length >= 2;
return (i) =>
i.pipe(
e ? kA((o, n) => e(o, n, i)) : at,
tr(1),
A ? An(t) : yC(() => new Mo())
);
}
function MC() {
return GA((e, t) => {
let A,
i = !1;
e.subscribe(
SA(t, (o) => {
let n = A;
(A = o), i && t.next([n, o]), (i = !0);
})
);
});
}
function qc(e, t) {
return GA(Rf(e, t, arguments.length >= 2, !0));
}
function Ys(e = {}) {
let {
connector: t = () => new _(),
resetOnError: A = !0,
resetOnComplete: i = !0,
resetOnRefCountZero: o = !0,
} = e;
return (n) => {
let g,
r,
s,
I = 0,
Q = !1,
c = !1,
D = () => {
r?.unsubscribe(), (r = void 0);
},
h = () => {
D(), (g = s = void 0), (Q = c = !1);
},
p = () => {
let y = g;
h(), y?.unsubscribe();
};
return GA((y, L) => {
I++, !c && !Q && D();
let q = (s = s ?? t());
L.add(() => {
I--, I === 0 && !c && !Q && (r = Vc(p, o));
}),
q.subscribe(L),
!g &&
I > 0 &&
((g = new yo({
next: (fA) => q.next(fA),
error: (fA) => {
(c = !0), D(), (r = Vc(h, A, fA)), q.error(fA);
},
complete: () => {
(Q = !0), D(), (r = Vc(h, i)), q.complete();
},
})),
ne(y).subscribe(g));
})(n);
};
}
function Vc(e, t, ...A) {
if (t === !0) {
e();
return;
}
if (t === !1) return;
let i = new yo({
next: () => {
i.unsubscribe(), e();
},
});
return ne(t(...A)).subscribe(i);
}
function Ro(e, t, A) {
let i,
o = !1;
return (
e && typeof e == "object"
? ({
bufferSize: i = 1 / 0,
windowTime: t = 1 / 0,
refCount: o = !1,
scheduler: A,
} = e)
: (i = e ?? 1 / 0),
Ys({
connector: () => new Bi(i, t, A),
resetOnError: !0,
resetOnComplete: !1,
resetOnRefCountZero: o,
})
);
}
function xn(e) {
return kA((t, A) => e <= A);
}
function Ie(...e) {
let t = Ji(e);
return GA((A, i) => {
(t ? $o(e, A, t) : $o(e, A)).subscribe(i);
});
}
function ge(e, t) {
return GA((A, i) => {
let o = null,
n = 0,
g = !1,
r = () => g && !o && i.complete();
A.subscribe(
SA(
i,
(s) => {
o?.unsubscribe();
let I = 0,
Q = n++;
ne(e(s, Q)).subscribe(
(o = SA(
i,
(c) => i.next(t ? t(s, c, Q, I++) : c),
() => {
(o = null), r();
}
))
);
},
() => {
(g = !0), r();
}
)
);
});
}
function BA(e) {
return GA((t, A) => {
ne(e).subscribe(SA(A, () => A.complete(), Gs)), !A.closed && t.subscribe(A);
});
}
function Wc(e, t = !1) {
return GA((A, i) => {
let o = 0;
A.subscribe(
SA(i, (n) => {
let g = e(n, o++);
(g || t) && i.next(n), !g && i.complete();
})
);
});
}
function Be(e, t, A) {
let i = yA(e) || t || A ? { next: e, error: t, complete: A } : e;
return i
? GA((o, n) => {
var g;
(g = i.subscribe) === null || g === void 0 || g.call(i);
let r = !0;
o.subscribe(
SA(
n,
(s) => {
var I;
(I = i.next) === null || I === void 0 || I.call(i, s), n.next(s);
},
() => {