rx-nostr
Version:
A library based on RxJS, which allows Nostr applications to easily communicate with relays.
1,797 lines (1,796 loc) • 94.8 kB
JavaScript
var Ct = Object.defineProperty;
var jt = (n, e, t) => e in n ? Ct(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var h = (n, e, t) => (jt(n, typeof e != "symbol" ? e + "" : e, t), t);
class G extends Error {
}
class Pe extends G {
constructor(e) {
super(
`RxNostrWebSocketError: WebSocket was closed with code ${e} by relay.`
), this.code = e, this.name = "RxNostrWebSocketError";
}
}
class B extends G {
constructor(e) {
super(`RxNostrInvalidUsageError: ${e}`), this.name = "RxNostrInvalidUsageError";
}
}
class fe extends G {
constructor(e) {
super(`RxNostrEnvironmentError: ${e}`), this.name = "RxNostrEnvironmentError";
}
}
class Oe extends G {
constructor() {
super(
"RxNostrLogicError: This is rx-nostr's internal bug. Please report to the author of the library."
), this.name = "RxNostrLogicError";
}
}
class T extends G {
constructor() {
super(
"RxNostrAlreadyDisposedError: Attempted to access a disposed resource."
), this.name = "RxNostrAlreadyDisposedError";
}
}
const P = (n, e) => ({
...e,
...n
});
function Dt(n) {
if (typeof n.id != "string" || typeof n.sig != "string" || typeof n.kind != "number" || typeof n.pubkey != "string" || typeof n.content != "string" || typeof n.created_at != "number" || !Array.isArray(n.tags))
return !1;
for (let e = 0; e < n.tags.length; e++) {
const t = n.tags[e];
if (!Array.isArray(t))
return !1;
for (let r = 0; r < t.length; r++)
if (typeof t[r] == "object")
return !1;
}
return !0;
}
function xr(n, e) {
return Y(n, e) < 0 ? n : e;
}
function Or(n, e) {
return Y(n, e) < 0 ? e : n;
}
function Y(n, e) {
return n.id === e.id ? 0 : n.created_at < e.created_at || // https://github.com/nostr-protocol/nips/blob/master/16.md#replaceable-events
n.created_at === e.created_at && n.id < e.id ? -1 : 1;
}
function he(n) {
throw n;
}
function Nt(n) {
return {
async signEvent(e) {
var r, i;
const t = {
...e,
pubkey: e.pubkey ?? await ((r = window == null ? void 0 : window.nostr) == null ? void 0 : r.getPublicKey()) ?? he(
new fe(
"window.nostr.getPublicKey() is not found"
)
),
tags: [...e.tags ?? [], ...(n == null ? void 0 : n.tags) ?? []],
created_at: e.created_at ?? Math.floor(Date.now() / 1e3)
};
return Dt(t) ? t : await ((i = window == null ? void 0 : window.nostr) == null ? void 0 : i.signEvent(t)) ?? he(
new fe("window.nostr.signEvent() is not found")
);
},
getPublicKey() {
var e;
return ((e = window == null ? void 0 : window.nostr) == null ? void 0 : e.getPublicKey()) ?? he(
new fe(
"window.nostr.getPublicKey() is not found"
)
);
}
};
}
function Rr() {
return {
async signEvent(n) {
return n;
},
async getPublicKey() {
throw new B("noopSigner cannot calculate pubkey.");
}
};
}
const qt = (n) => P(n, {
signer: Nt(),
connectionStrategy: "lazy",
retry: {
strategy: "exponential",
maxCount: 5,
initialDelay: 1e3
},
disconnectTimeout: 1e4,
eoseTimeout: 30 * 1e3,
okTimeout: 30 * 1e3,
authTimeout: 30 * 1e3,
skipVerify: !1,
skipValidateFilterMatching: !1,
skipExpirationCheck: !1,
skipFetchNip11: !1
}), $r = async () => !0;
function Ye(n) {
return "length" in n ? n.map(_e) : [_e(n)];
}
function _e(n) {
return {
...n,
since: n.since ? Ce(n.since) : void 0,
until: n.until ? Ce(n.until) : void 0
};
}
function Ce(n) {
return typeof n == "number" ? n : n();
}
async function Lt(n) {
try {
const e = new URL(n);
return e.protocol = e.protocol.replace(/^ws(s?):/, "http$1:"), await (await fetch(e.toString(), {
headers: { Accept: "application/nostr+json" }
})).json();
} catch {
return {};
}
}
function je(n, e) {
try {
return n();
} catch (t) {
return e instanceof Function ? e(t) : e;
}
}
function k(n) {
let e = "";
try {
e = n.trim();
const t = new URL(e);
t.hash = "", t.pathname = je(() => decodeURI(t.pathname), t.pathname), t.pathname = t.pathname.replace(/\/$/, ""), t.hostname = t.hostname.replace(/\.$/, ""), t.searchParams.sort(), t.search = je(() => decodeURIComponent(t.search), t.search);
let r = t.toString();
return t.search || (r = r.replace(/\/$/, "")), r;
} catch {
return e;
}
}
class U extends Map {
constructor(e) {
if (super(), !!e)
for (const [t, r] of Object.entries(e))
this.set(k(t), r);
}
get(e) {
return super.get(k(e));
}
getMany(e) {
const t = [];
for (const r of new Set(e.map(k))) {
const i = this.get(r);
i !== void 0 && t.push(i);
}
return t;
}
set(e, t) {
return super.set(k(e), t);
}
has(e) {
return super.has(k(e));
}
delete(e) {
return super.delete(k(e));
}
toObject() {
const e = {};
for (const [t, r] of this.entries())
e[t] = r;
return e;
}
toKeys() {
return [...super.keys()];
}
toValues() {
return [...super.values()];
}
copy() {
return new U(this.toObject());
}
}
class te {
static async getValue(e, t, r) {
if (!(r != null && r.skipCache)) {
const i = await this.cache.get(e);
if (i)
return t(i);
}
if (!(r != null && r.skipFetch)) {
const i = await this.fetch(e);
if (i)
return t(i);
}
return t(this.default);
}
/**
* Return cached or `set()`'ed NIP-11 information.
*/
static get(e) {
const t = this.cache.get(e);
if (t && !(t instanceof Promise))
return t;
}
/**
* Cache fetched information then return it.
*/
static async fetch(e) {
const t = Lt(e);
return this.cache.set(e, t), t.then((r) => {
this.cache.set(e, r);
}), t;
}
/**
* Return cached or `set()`'ed NIP-11 information,
* or cache fetched information then return it.
*/
static async getOrFetch(e) {
return this.cache.get(e) ?? this.fetch(e);
}
/**
* Set NIP-11 information manually for given relay URL.
*/
static set(e, t) {
this.cache.set(e, t);
}
/**
* Get NIP-11 information for fallback.
*/
static getDefault() {
return this.default;
}
/**
* Set NIP-11 information for fallback.
*/
static setDefault(e) {
this.default = e;
}
/**
* Forget cached NIP-11 information for given relay URL.
*/
static forget(e) {
this.cache.delete(e);
}
/**
* Forget all cached NIP-11 information.
*
* This doesn't erase `setDefault()`'ed value.
* If you want it, you can `setDefault({})` instead.
*/
static forgetAll() {
this.cache.clear();
}
}
h(te, "cache", new U()), h(te, "default", {});
function Ut(n) {
return n instanceof Uint8Array || n != null && typeof n == "object" && n.constructor.name === "Uint8Array";
}
function Mt(n, ...e) {
if (!Ut(n))
throw new Error("Uint8Array expected");
if (e.length > 0 && !e.includes(n.length))
throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`);
}
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
new Uint8Array(new Uint32Array([287454020]).buffer)[0];
const Ft = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
function Vt(n) {
Mt(n);
let e = "";
for (let t = 0; t < n.length; t++)
e += Ft[n[t]];
return e;
}
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function Wt(n) {
return n instanceof Uint8Array || n != null && typeof n == "object" && n.constructor.name === "Uint8Array";
}
// @__NO_SIDE_EFFECTS__
function zt(...n) {
const e = (s) => s, t = (s, o) => (u) => s(o(u)), r = n.map((s) => s.encode).reduceRight(t, e), i = n.map((s) => s.decode).reduce(t, e);
return { encode: r, decode: i };
}
// @__NO_SIDE_EFFECTS__
function Kt(n) {
return {
encode: (e) => {
if (!Array.isArray(e) || e.length && typeof e[0] != "number")
throw new Error("alphabet.encode input should be an array of numbers");
return e.map((t) => {
if (t < 0 || t >= n.length)
throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${n.length})`);
return n[t];
});
},
decode: (e) => {
if (!Array.isArray(e) || e.length && typeof e[0] != "string")
throw new Error("alphabet.decode input should be array of strings");
return e.map((t) => {
if (typeof t != "string")
throw new Error(`alphabet.decode: not string element=${t}`);
const r = n.indexOf(t);
if (r === -1)
throw new Error(`Unknown letter: "${t}". Allowed: ${n}`);
return r;
});
}
};
}
// @__NO_SIDE_EFFECTS__
function Bt(n = "") {
if (typeof n != "string")
throw new Error("join separator should be string");
return {
encode: (e) => {
if (!Array.isArray(e) || e.length && typeof e[0] != "string")
throw new Error("join.encode input should be array of strings");
for (let t of e)
if (typeof t != "string")
throw new Error(`join.encode: non-string input=${t}`);
return e.join(n);
},
decode: (e) => {
if (typeof e != "string")
throw new Error("join.decode input should be string");
return e.split(n);
}
};
}
const Qe = /* @__NO_SIDE_EFFECTS__ */ (n, e) => e ? /* @__PURE__ */ Qe(e, n % e) : n, ne = /* @__NO_SIDE_EFFECTS__ */ (n, e) => n + (e - /* @__PURE__ */ Qe(n, e));
// @__NO_SIDE_EFFECTS__
function ve(n, e, t, r) {
if (!Array.isArray(n))
throw new Error("convertRadix2: data should be array");
if (e <= 0 || e > 32)
throw new Error(`convertRadix2: wrong from=${e}`);
if (t <= 0 || t > 32)
throw new Error(`convertRadix2: wrong to=${t}`);
if (/* @__PURE__ */ ne(e, t) > 32)
throw new Error(`convertRadix2: carry overflow from=${e} to=${t} carryBits=${/* @__PURE__ */ ne(e, t)}`);
let i = 0, s = 0;
const o = 2 ** t - 1, u = [];
for (const a of n) {
if (a >= 2 ** e)
throw new Error(`convertRadix2: invalid data word=${a} from=${e}`);
if (i = i << e | a, s + e > 32)
throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);
for (s += e; s >= t; s -= t)
u.push((i >> s - t & o) >>> 0);
i &= 2 ** s - 1;
}
if (i = i << t - s & o, !r && s >= e)
throw new Error("Excess padding");
if (!r && i)
throw new Error(`Non-zero padding: ${i}`);
return r && s > 0 && u.push(i >>> 0), u;
}
// @__NO_SIDE_EFFECTS__
function Ht(n, e = !1) {
if (n <= 0 || n > 32)
throw new Error("radix2: bits should be in (0..32]");
if (/* @__PURE__ */ ne(8, n) > 32 || /* @__PURE__ */ ne(n, 8) > 32)
throw new Error("radix2: carry overflow");
return {
encode: (t) => {
if (!Wt(t))
throw new Error("radix2.encode input should be Uint8Array");
return /* @__PURE__ */ ve(Array.from(t), 8, n, !e);
},
decode: (t) => {
if (!Array.isArray(t) || t.length && typeof t[0] != "number")
throw new Error("radix2.decode input should be array of numbers");
return Uint8Array.from(/* @__PURE__ */ ve(t, n, 8, e));
}
};
}
// @__NO_SIDE_EFFECTS__
function De(n) {
if (typeof n != "function")
throw new Error("unsafeWrapper fn should be function");
return function(...e) {
try {
return n.apply(null, e);
} catch {
}
};
}
const ge = /* @__PURE__ */ zt(/* @__PURE__ */ Kt("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ Bt("")), Ne = [996825010, 642813549, 513874426, 1027748829, 705979059];
// @__NO_SIDE_EFFECTS__
function W(n) {
const e = n >> 25;
let t = (n & 33554431) << 5;
for (let r = 0; r < Ne.length; r++)
(e >> r & 1) === 1 && (t ^= Ne[r]);
return t;
}
// @__NO_SIDE_EFFECTS__
function qe(n, e, t = 1) {
const r = n.length;
let i = 1;
for (let s = 0; s < r; s++) {
const o = n.charCodeAt(s);
if (o < 33 || o > 126)
throw new Error(`Invalid prefix (${n})`);
i = /* @__PURE__ */ W(i) ^ o >> 5;
}
i = /* @__PURE__ */ W(i);
for (let s = 0; s < r; s++)
i = /* @__PURE__ */ W(i) ^ n.charCodeAt(s) & 31;
for (let s of e)
i = /* @__PURE__ */ W(i) ^ s;
for (let s = 0; s < 6; s++)
i = /* @__PURE__ */ W(i);
return i ^= t, ge.encode(/* @__PURE__ */ ve([i % 2 ** 30], 30, 5, !1));
}
// @__NO_SIDE_EFFECTS__
function Gt(n) {
const e = n === "bech32" ? 1 : 734539939, t = /* @__PURE__ */ Ht(5), r = t.decode, i = t.encode, s = /* @__PURE__ */ De(r);
function o(c, f, d = 90) {
if (typeof c != "string")
throw new Error(`bech32.encode prefix should be string, not ${typeof c}`);
if (!Array.isArray(f) || f.length && typeof f[0] != "number")
throw new Error(`bech32.encode words should be array of numbers, not ${typeof f}`);
if (c.length === 0)
throw new TypeError(`Invalid prefix length ${c.length}`);
const y = c.length + 7 + f.length;
if (d !== !1 && y > d)
throw new TypeError(`Length ${y} exceeds limit ${d}`);
const b = c.toLowerCase(), p = /* @__PURE__ */ qe(b, f, e);
return `${b}1${ge.encode(f)}${p}`;
}
function u(c, f = 90) {
if (typeof c != "string")
throw new Error(`bech32.decode input should be string, not ${typeof c}`);
if (c.length < 8 || f !== !1 && c.length > f)
throw new TypeError(`Wrong string length: ${c.length} (${c}). Expected (8..${f})`);
const d = c.toLowerCase();
if (c !== d && c !== c.toUpperCase())
throw new Error("String must be lowercase or uppercase");
const y = d.lastIndexOf("1");
if (y === 0 || y === -1)
throw new Error('Letter "1" must be present between prefix and data only');
const b = d.slice(0, y), p = d.slice(y + 1);
if (p.length < 6)
throw new Error("Data must be at least 6 characters long");
const g = ge.decode(p).slice(0, -6), x = /* @__PURE__ */ qe(b, g, e);
if (!p.endsWith(x))
throw new Error(`Invalid checksum in ${c}: expected "${x}"`);
return { prefix: b, words: g };
}
const a = /* @__PURE__ */ De(u);
function l(c) {
const { prefix: f, words: d } = u(c, !1);
return { prefix: f, words: d, bytes: r(d) };
}
return { encode: o, decode: u, decodeToBytes: l, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: s, toWords: i };
}
const Le = /* @__PURE__ */ Gt("bech32");
function Ar(n) {
const { words: e } = Le.decode(n), t = new Uint8Array(Le.fromWords(e));
return Vt(t);
}
function Xe(n, e, t) {
return Array.isArray(e) ? e.some((r) => Ue(n, r, t)) : Ue(n, e, t);
}
function Ue(n, e, t) {
const { sinceInclusive: r, untilInclusive: i } = P(t ?? {}, {
sinceInclusive: !0,
untilInclusive: !0
});
if (e.ids && e.ids.every((s) => !n.id.startsWith(s)) || e.kinds && !e.kinds.includes(n.kind) || e.authors && e.authors.every((s) => !n.pubkey.startsWith(s)) || e.since && (r && !(e.since <= n.created_at) || !r && !(e.since < n.created_at)) || e.until && (i && !(n.created_at <= e.until) || !i && !(n.created_at < e.until)))
return !1;
for (const [s, o] of Object.entries(e)) {
if (!s.startsWith("#") || !Array.isArray(o))
continue;
const u = s.slice(1);
if (!n.tags.find(
([a, l]) => u === a && o.includes(l)
))
return !1;
}
return !0;
}
function Je(n, e) {
const t = n.tags.find((r) => r[0] === "expiration");
if (!t)
return !1;
try {
const r = Number(t[1]);
return Number.isInteger(r) ? r <= (e ?? Math.floor(Date.now() / 1e3)) : !1;
} catch {
return !1;
}
}
var me = function(n, e) {
return me = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, r) {
t.__proto__ = r;
} || function(t, r) {
for (var i in r)
Object.prototype.hasOwnProperty.call(r, i) && (t[i] = r[i]);
}, me(n, e);
};
function _(n, e) {
if (typeof e != "function" && e !== null)
throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
me(n, e);
function t() {
this.constructor = n;
}
n.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
}
function Yt(n, e, t, r) {
function i(s) {
return s instanceof t ? s : new t(function(o) {
o(s);
});
}
return new (t || (t = Promise))(function(s, o) {
function u(c) {
try {
l(r.next(c));
} catch (f) {
o(f);
}
}
function a(c) {
try {
l(r.throw(c));
} catch (f) {
o(f);
}
}
function l(c) {
c.done ? s(c.value) : i(c.value).then(u, a);
}
l((r = r.apply(n, e || [])).next());
});
}
function Ze(n, e) {
var t = { label: 0, sent: function() {
if (s[0] & 1)
throw s[1];
return s[1];
}, trys: [], ops: [] }, r, i, s, o;
return o = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
return this;
}), o;
function u(l) {
return function(c) {
return a([l, c]);
};
}
function a(l) {
if (r)
throw new TypeError("Generator is already executing.");
for (; o && (o = 0, l[0] && (t = 0)), t; )
try {
if (r = 1, i && (s = l[0] & 2 ? i.return : l[0] ? i.throw || ((s = i.return) && s.call(i), 0) : i.next) && !(s = s.call(i, l[1])).done)
return s;
switch (i = 0, s && (l = [l[0] & 2, s.value]), l[0]) {
case 0:
case 1:
s = l;
break;
case 4:
return t.label++, { value: l[1], done: !1 };
case 5:
t.label++, i = l[1], l = [0];
continue;
case 7:
l = t.ops.pop(), t.trys.pop();
continue;
default:
if (s = t.trys, !(s = s.length > 0 && s[s.length - 1]) && (l[0] === 6 || l[0] === 2)) {
t = 0;
continue;
}
if (l[0] === 3 && (!s || l[1] > s[0] && l[1] < s[3])) {
t.label = l[1];
break;
}
if (l[0] === 6 && t.label < s[1]) {
t.label = s[1], s = l;
break;
}
if (s && t.label < s[2]) {
t.label = s[2], t.ops.push(l);
break;
}
s[2] && t.ops.pop(), t.trys.pop();
continue;
}
l = e.call(n, t);
} catch (c) {
l = [6, c], i = 0;
} finally {
r = s = 0;
}
if (l[0] & 5)
throw l[1];
return { value: l[0] ? l[1] : void 0, done: !0 };
}
}
function F(n) {
var e = typeof Symbol == "function" && Symbol.iterator, t = e && n[e], r = 0;
if (t)
return t.call(n);
if (n && typeof n.length == "number")
return {
next: function() {
return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
}
};
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function D(n, e) {
var t = typeof Symbol == "function" && n[Symbol.iterator];
if (!t)
return n;
var r = t.call(n), i, s = [], o;
try {
for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; )
s.push(i.value);
} catch (u) {
o = { error: u };
} finally {
try {
i && !i.done && (t = r.return) && t.call(r);
} finally {
if (o)
throw o.error;
}
}
return s;
}
function N(n, e, t) {
if (t || arguments.length === 2)
for (var r = 0, i = e.length, s; r < i; r++)
(s || !(r in e)) && (s || (s = Array.prototype.slice.call(e, 0, r)), s[r] = e[r]);
return n.concat(s || Array.prototype.slice.call(e));
}
function M(n) {
return this instanceof M ? (this.v = n, this) : new M(n);
}
function Qt(n, e, t) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var r = t.apply(n, e || []), i, s = [];
return i = {}, o("next"), o("throw"), o("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function o(d) {
r[d] && (i[d] = function(y) {
return new Promise(function(b, p) {
s.push([d, y, b, p]) > 1 || u(d, y);
});
});
}
function u(d, y) {
try {
a(r[d](y));
} catch (b) {
f(s[0][3], b);
}
}
function a(d) {
d.value instanceof M ? Promise.resolve(d.value.v).then(l, c) : f(s[0][2], d);
}
function l(d) {
u("next", d);
}
function c(d) {
u("throw", d);
}
function f(d, y) {
d(y), s.shift(), s.length && u(s[0][0], s[0][1]);
}
}
function Xt(n) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var e = n[Symbol.asyncIterator], t;
return e ? e.call(n) : (n = typeof F == "function" ? F(n) : n[Symbol.iterator](), t = {}, r("next"), r("throw"), r("return"), t[Symbol.asyncIterator] = function() {
return this;
}, t);
function r(s) {
t[s] = n[s] && function(o) {
return new Promise(function(u, a) {
o = n[s](o), i(u, a, o.done, o.value);
});
};
}
function i(s, o, u, a) {
Promise.resolve(a).then(function(l) {
s({ value: l, done: u });
}, o);
}
}
function w(n) {
return typeof n == "function";
}
function oe(n) {
var e = function(r) {
Error.call(r), r.stack = new Error().stack;
}, t = n(e);
return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
var de = oe(function(n) {
return function(t) {
n(this), this.message = t ? t.length + ` errors occurred during unsubscription:
` + t.map(function(r, i) {
return i + 1 + ") " + r.toString();
}).join(`
`) : "", this.name = "UnsubscriptionError", this.errors = t;
};
});
function re(n, e) {
if (n) {
var t = n.indexOf(e);
0 <= t && n.splice(t, 1);
}
}
var Q = function() {
function n(e) {
this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
}
return n.prototype.unsubscribe = function() {
var e, t, r, i, s;
if (!this.closed) {
this.closed = !0;
var o = this._parentage;
if (o)
if (this._parentage = null, Array.isArray(o))
try {
for (var u = F(o), a = u.next(); !a.done; a = u.next()) {
var l = a.value;
l.remove(this);
}
} catch (p) {
e = { error: p };
} finally {
try {
a && !a.done && (t = u.return) && t.call(u);
} finally {
if (e)
throw e.error;
}
}
else
o.remove(this);
var c = this.initialTeardown;
if (w(c))
try {
c();
} catch (p) {
s = p instanceof de ? p.errors : [p];
}
var f = this._finalizers;
if (f) {
this._finalizers = null;
try {
for (var d = F(f), y = d.next(); !y.done; y = d.next()) {
var b = y.value;
try {
Me(b);
} catch (p) {
s = s ?? [], p instanceof de ? s = N(N([], D(s)), D(p.errors)) : s.push(p);
}
}
} catch (p) {
r = { error: p };
} finally {
try {
y && !y.done && (i = d.return) && i.call(d);
} finally {
if (r)
throw r.error;
}
}
}
if (s)
throw new de(s);
}
}, n.prototype.add = function(e) {
var t;
if (e && e !== this)
if (this.closed)
Me(e);
else {
if (e instanceof n) {
if (e.closed || e._hasParent(this))
return;
e._addParent(this);
}
(this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(e);
}
}, n.prototype._hasParent = function(e) {
var t = this._parentage;
return t === e || Array.isArray(t) && t.includes(e);
}, n.prototype._addParent = function(e) {
var t = this._parentage;
this._parentage = Array.isArray(t) ? (t.push(e), t) : t ? [t, e] : e;
}, n.prototype._removeParent = function(e) {
var t = this._parentage;
t === e ? this._parentage = null : Array.isArray(t) && re(t, e);
}, n.prototype.remove = function(e) {
var t = this._finalizers;
t && re(t, e), e instanceof n && e._removeParent(this);
}, n.EMPTY = function() {
var e = new n();
return e.closed = !0, e;
}(), n;
}(), et = Q.EMPTY;
function tt(n) {
return n instanceof Q || n && "closed" in n && w(n.remove) && w(n.add) && w(n.unsubscribe);
}
function Me(n) {
w(n) ? n() : n.unsubscribe();
}
var nt = {
onUnhandledError: null,
onStoppedNotification: null,
Promise: void 0,
useDeprecatedSynchronousErrorHandling: !1,
useDeprecatedNextContext: !1
}, we = {
setTimeout: function(n, e) {
for (var t = [], r = 2; r < arguments.length; r++)
t[r - 2] = arguments[r];
var i = we.delegate;
return i != null && i.setTimeout ? i.setTimeout.apply(i, N([n, e], D(t))) : setTimeout.apply(void 0, N([n, e], D(t)));
},
clearTimeout: function(n) {
var e = we.delegate;
return ((e == null ? void 0 : e.clearTimeout) || clearTimeout)(n);
},
delegate: void 0
};
function rt(n) {
we.setTimeout(function() {
throw n;
});
}
function H() {
}
function ee(n) {
n();
}
var Re = function(n) {
_(e, n);
function e(t) {
var r = n.call(this) || this;
return r.isStopped = !1, t ? (r.destination = t, tt(t) && t.add(r)) : r.destination = tn, r;
}
return e.create = function(t, r, i) {
return new ie(t, r, i);
}, e.prototype.next = function(t) {
this.isStopped || this._next(t);
}, e.prototype.error = function(t) {
this.isStopped || (this.isStopped = !0, this._error(t));
}, e.prototype.complete = function() {
this.isStopped || (this.isStopped = !0, this._complete());
}, e.prototype.unsubscribe = function() {
this.closed || (this.isStopped = !0, n.prototype.unsubscribe.call(this), this.destination = null);
}, e.prototype._next = function(t) {
this.destination.next(t);
}, e.prototype._error = function(t) {
try {
this.destination.error(t);
} finally {
this.unsubscribe();
}
}, e.prototype._complete = function() {
try {
this.destination.complete();
} finally {
this.unsubscribe();
}
}, e;
}(Q), Jt = Function.prototype.bind;
function ye(n, e) {
return Jt.call(n, e);
}
var Zt = function() {
function n(e) {
this.partialObserver = e;
}
return n.prototype.next = function(e) {
var t = this.partialObserver;
if (t.next)
try {
t.next(e);
} catch (r) {
Z(r);
}
}, n.prototype.error = function(e) {
var t = this.partialObserver;
if (t.error)
try {
t.error(e);
} catch (r) {
Z(r);
}
else
Z(e);
}, n.prototype.complete = function() {
var e = this.partialObserver;
if (e.complete)
try {
e.complete();
} catch (t) {
Z(t);
}
}, n;
}(), ie = function(n) {
_(e, n);
function e(t, r, i) {
var s = n.call(this) || this, o;
if (w(t) || !t)
o = {
next: t ?? void 0,
error: r ?? void 0,
complete: i ?? void 0
};
else {
var u;
s && nt.useDeprecatedNextContext ? (u = Object.create(t), u.unsubscribe = function() {
return s.unsubscribe();
}, o = {
next: t.next && ye(t.next, u),
error: t.error && ye(t.error, u),
complete: t.complete && ye(t.complete, u)
}) : o = t;
}
return s.destination = new Zt(o), s;
}
return e;
}(Re);
function Z(n) {
rt(n);
}
function en(n) {
throw n;
}
var tn = {
closed: !0,
next: H,
error: en,
complete: H
}, $e = function() {
return typeof Symbol == "function" && Symbol.observable || "@@observable";
}();
function C(n) {
return n;
}
function V() {
for (var n = [], e = 0; e < arguments.length; e++)
n[e] = arguments[e];
return it(n);
}
function it(n) {
return n.length === 0 ? C : n.length === 1 ? n[0] : function(t) {
return n.reduce(function(r, i) {
return i(r);
}, t);
};
}
var R = function() {
function n(e) {
e && (this._subscribe = e);
}
return n.prototype.lift = function(e) {
var t = new n();
return t.source = this, t.operator = e, t;
}, n.prototype.subscribe = function(e, t, r) {
var i = this, s = rn(e) ? e : new ie(e, t, r);
return ee(function() {
var o = i, u = o.operator, a = o.source;
s.add(u ? u.call(s, a) : a ? i._subscribe(s) : i._trySubscribe(s));
}), s;
}, n.prototype._trySubscribe = function(e) {
try {
return this._subscribe(e);
} catch (t) {
e.error(t);
}
}, n.prototype.forEach = function(e, t) {
var r = this;
return t = Fe(t), new t(function(i, s) {
var o = new ie({
next: function(u) {
try {
e(u);
} catch (a) {
s(a), o.unsubscribe();
}
},
error: s,
complete: i
});
r.subscribe(o);
});
}, n.prototype._subscribe = function(e) {
var t;
return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(e);
}, n.prototype[$e] = function() {
return this;
}, n.prototype.pipe = function() {
for (var e = [], t = 0; t < arguments.length; t++)
e[t] = arguments[t];
return it(e)(this);
}, n.prototype.toPromise = function(e) {
var t = this;
return e = Fe(e), new e(function(r, i) {
var s;
t.subscribe(function(o) {
return s = o;
}, function(o) {
return i(o);
}, function() {
return r(s);
});
});
}, n.create = function(e) {
return new n(e);
}, n;
}();
function Fe(n) {
var e;
return (e = n ?? nt.Promise) !== null && e !== void 0 ? e : Promise;
}
function nn(n) {
return n && w(n.next) && w(n.error) && w(n.complete);
}
function rn(n) {
return n && n instanceof Re || nn(n) && tt(n);
}
function sn(n) {
return w(n == null ? void 0 : n.lift);
}
function E(n) {
return function(e) {
if (sn(e))
return e.lift(function(t) {
try {
return n(t, this);
} catch (r) {
this.error(r);
}
});
throw new TypeError("Unable to lift unknown Observable type");
};
}
function m(n, e, t, r, i) {
return new st(n, e, t, r, i);
}
var st = function(n) {
_(e, n);
function e(t, r, i, s, o, u) {
var a = n.call(this, t) || this;
return a.onFinalize = o, a.shouldUnsubscribe = u, a._next = r ? function(l) {
try {
r(l);
} catch (c) {
t.error(c);
}
} : n.prototype._next, a._error = s ? function(l) {
try {
s(l);
} catch (c) {
t.error(c);
} finally {
this.unsubscribe();
}
} : n.prototype._error, a._complete = i ? function() {
try {
i();
} catch (l) {
t.error(l);
} finally {
this.unsubscribe();
}
} : n.prototype._complete, a;
}
return e.prototype.unsubscribe = function() {
var t;
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
var r = this.closed;
n.prototype.unsubscribe.call(this), !r && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
}
}, e;
}(Re), on = oe(function(n) {
return function() {
n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
};
}), v = function(n) {
_(e, n);
function e() {
var t = n.call(this) || this;
return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
}
return e.prototype.lift = function(t) {
var r = new Ve(this, this);
return r.operator = t, r;
}, e.prototype._throwIfClosed = function() {
if (this.closed)
throw new on();
}, e.prototype.next = function(t) {
var r = this;
ee(function() {
var i, s;
if (r._throwIfClosed(), !r.isStopped) {
r.currentObservers || (r.currentObservers = Array.from(r.observers));
try {
for (var o = F(r.currentObservers), u = o.next(); !u.done; u = o.next()) {
var a = u.value;
a.next(t);
}
} catch (l) {
i = { error: l };
} finally {
try {
u && !u.done && (s = o.return) && s.call(o);
} finally {
if (i)
throw i.error;
}
}
}
});
}, e.prototype.error = function(t) {
var r = this;
ee(function() {
if (r._throwIfClosed(), !r.isStopped) {
r.hasError = r.isStopped = !0, r.thrownError = t;
for (var i = r.observers; i.length; )
i.shift().error(t);
}
});
}, e.prototype.complete = function() {
var t = this;
ee(function() {
if (t._throwIfClosed(), !t.isStopped) {
t.isStopped = !0;
for (var r = t.observers; r.length; )
r.shift().complete();
}
});
}, e.prototype.unsubscribe = function() {
this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
}, Object.defineProperty(e.prototype, "observed", {
get: function() {
var t;
return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
},
enumerable: !1,
configurable: !0
}), e.prototype._trySubscribe = function(t) {
return this._throwIfClosed(), n.prototype._trySubscribe.call(this, t);
}, e.prototype._subscribe = function(t) {
return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
}, e.prototype._innerSubscribe = function(t) {
var r = this, i = this, s = i.hasError, o = i.isStopped, u = i.observers;
return s || o ? et : (this.currentObservers = null, u.push(t), new Q(function() {
r.currentObservers = null, re(u, t);
}));
}, e.prototype._checkFinalizedStatuses = function(t) {
var r = this, i = r.hasError, s = r.thrownError, o = r.isStopped;
i ? t.error(s) : o && t.complete();
}, e.prototype.asObservable = function() {
var t = new R();
return t.source = this, t;
}, e.create = function(t, r) {
return new Ve(t, r);
}, e;
}(R), Ve = function(n) {
_(e, n);
function e(t, r) {
var i = n.call(this) || this;
return i.destination = t, i.source = r, i;
}
return e.prototype.next = function(t) {
var r, i;
(i = (r = this.destination) === null || r === void 0 ? void 0 : r.next) === null || i === void 0 || i.call(r, t);
}, e.prototype.error = function(t) {
var r, i;
(i = (r = this.destination) === null || r === void 0 ? void 0 : r.error) === null || i === void 0 || i.call(r, t);
}, e.prototype.complete = function() {
var t, r;
(r = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || r === void 0 || r.call(t);
}, e.prototype._subscribe = function(t) {
var r, i;
return (i = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t)) !== null && i !== void 0 ? i : et;
}, e;
}(v), un = function(n) {
_(e, n);
function e(t) {
var r = n.call(this) || this;
return r._value = t, r;
}
return Object.defineProperty(e.prototype, "value", {
get: function() {
return this.getValue();
},
enumerable: !1,
configurable: !0
}), e.prototype._subscribe = function(t) {
var r = n.prototype._subscribe.call(this, t);
return !r.closed && t.next(this._value), r;
}, e.prototype.getValue = function() {
var t = this, r = t.hasError, i = t.thrownError, s = t._value;
if (r)
throw i;
return this._throwIfClosed(), s;
}, e.prototype.next = function(t) {
n.prototype.next.call(this, this._value = t);
}, e;
}(v), ot = {
now: function() {
return (ot.delegate || Date).now();
},
delegate: void 0
}, cn = function(n) {
_(e, n);
function e(t, r) {
return n.call(this) || this;
}
return e.prototype.schedule = function(t, r) {
return this;
}, e;
}(Q), se = {
setInterval: function(n, e) {
for (var t = [], r = 2; r < arguments.length; r++)
t[r - 2] = arguments[r];
var i = se.delegate;
return i != null && i.setInterval ? i.setInterval.apply(i, N([n, e], D(t))) : setInterval.apply(void 0, N([n, e], D(t)));
},
clearInterval: function(n) {
var e = se.delegate;
return ((e == null ? void 0 : e.clearInterval) || clearInterval)(n);
},
delegate: void 0
}, an = function(n) {
_(e, n);
function e(t, r) {
var i = n.call(this, t, r) || this;
return i.scheduler = t, i.work = r, i.pending = !1, i;
}
return e.prototype.schedule = function(t, r) {
var i;
if (r === void 0 && (r = 0), this.closed)
return this;
this.state = t;
var s = this.id, o = this.scheduler;
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;
}, e.prototype.requestAsyncId = function(t, r, i) {
return i === void 0 && (i = 0), se.setInterval(t.flush.bind(t, this), i);
}, e.prototype.recycleAsyncId = function(t, r, i) {
if (i === void 0 && (i = 0), i != null && this.delay === i && this.pending === !1)
return r;
r != null && se.clearInterval(r);
}, e.prototype.execute = function(t, r) {
if (this.closed)
return new Error("executing a cancelled action");
this.pending = !1;
var i = this._execute(t, r);
if (i)
return i;
this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
}, e.prototype._execute = function(t, r) {
var i = !1, s;
try {
this.work(t);
} catch (o) {
i = !0, s = o || new Error("Scheduled action threw falsy error");
}
if (i)
return this.unsubscribe(), s;
}, e.prototype.unsubscribe = function() {
if (!this.closed) {
var t = this, r = t.id, i = t.scheduler, s = i.actions;
this.work = this.state = this.scheduler = null, this.pending = !1, re(s, this), r != null && (this.id = this.recycleAsyncId(i, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
}
}, e;
}(cn), We = function() {
function n(e, t) {
t === void 0 && (t = n.now), this.schedulerActionCtor = e, this.now = t;
}
return n.prototype.schedule = function(e, t, r) {
return t === void 0 && (t = 0), new this.schedulerActionCtor(this, e).schedule(r, t);
}, n.now = ot.now, n;
}(), ln = function(n) {
_(e, n);
function e(t, r) {
r === void 0 && (r = We.now);
var i = n.call(this, t, r) || this;
return i.actions = [], i._active = !1, i;
}
return e.prototype.flush = function(t) {
var r = this.actions;
if (this._active) {
r.push(t);
return;
}
var i;
this._active = !0;
do
if (i = t.execute(t.state, t.delay))
break;
while (t = r.shift());
if (this._active = !1, i) {
for (; t = r.shift(); )
t.unsubscribe();
throw i;
}
}, e;
}(We), Ae = new ln(an), fn = Ae, X = new R(function(n) {
return n.complete();
});
function ut(n) {
return n && w(n.schedule);
}
function Ie(n) {
return n[n.length - 1];
}
function hn(n) {
return w(Ie(n)) ? n.pop() : void 0;
}
function ue(n) {
return ut(Ie(n)) ? n.pop() : void 0;
}
function dn(n, e) {
return typeof Ie(n) == "number" ? n.pop() : e;
}
var ct = function(n) {
return n && typeof n.length == "number" && typeof n != "function";
};
function at(n) {
return w(n == null ? void 0 : n.then);
}
function lt(n) {
return w(n[$e]);
}
function ft(n) {
return Symbol.asyncIterator && w(n == null ? void 0 : n[Symbol.asyncIterator]);
}
function ht(n) {
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.");
}
function yn() {
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
}
var dt = yn();
function yt(n) {
return w(n == null ? void 0 : n[dt]);
}
function bt(n) {
return Qt(this, arguments, function() {
var t, r, i, s;
return Ze(this, function(o) {
switch (o.label) {
case 0:
t = n.getReader(), o.label = 1;
case 1:
o.trys.push([1, , 9, 10]), o.label = 2;
case 2:
return [4, M(t.read())];
case 3:
return r = o.sent(), i = r.value, s = r.done, s ? [4, M(void 0)] : [3, 5];
case 4:
return [2, o.sent()];
case 5:
return [4, M(i)];
case 6:
return [4, o.sent()];
case 7:
return o.sent(), [3, 2];
case 8:
return [3, 10];
case 9:
return t.releaseLock(), [7];
case 10:
return [2];
}
});
});
}
function pt(n) {
return w(n == null ? void 0 : n.getReader);
}
function $(n) {
if (n instanceof R)
return n;
if (n != null) {
if (lt(n))
return bn(n);
if (ct(n))
return pn(n);
if (at(n))
return vn(n);
if (ft(n))
return vt(n);
if (yt(n))
return gn(n);
if (pt(n))
return mn(n);
}
throw ht(n);
}
function bn(n) {
return new R(function(e) {
var t = n[$e]();
if (w(t.subscribe))
return t.subscribe(e);
throw new TypeError("Provided object does not correctly implement Symbol.observable");
});
}
function pn(n) {
return new R(function(e) {
for (var t = 0; t < n.length && !e.closed; t++)
e.next(n[t]);
e.complete();
});
}
function vn(n) {
return new R(function(e) {
n.then(function(t) {
e.closed || (e.next(t), e.complete());
}, function(t) {
return e.error(t);
}).then(null, rt);
});
}
function gn(n) {
return new R(function(e) {
var t, r;
try {
for (var i = F(n), s = i.next(); !s.done; s = i.next()) {
var o = s.value;
if (e.next(o), e.closed)
return;
}
} catch (u) {
t = { error: u };
} finally {
try {
s && !s.done && (r = i.return) && r.call(i);
} finally {
if (t)
throw t.error;
}
}
e.complete();
});
}
function vt(n) {
return new R(function(e) {
wn(n, e).catch(function(t) {
return e.error(t);
});
});
}
function mn(n) {
return vt(bt(n));
}
function wn(n, e) {
var t, r, i, s;
return Yt(this, void 0, void 0, function() {
var o, u;
return Ze(this, function(a) {
switch (a.label) {
case 0:
a.trys.push([0, 5, 6, 11]), t = Xt(n), a.label = 1;
case 1:
return [4, t.next()];
case 2:
if (r = a.sent(), !!r.done)
return [3, 4];
if (o = r.value, e.next(o), e.closed)
return [2];
a.label = 3;
case 3:
return [3, 1];
case 4:
return [3, 11];
case 5:
return u = a.sent(), i = { error: u }, [3, 11];
case 6:
return a.trys.push([6, , 9, 10]), r && !r.done && (s = t.return) ? [4, s.call(t)] : [3, 8];
case 7:
a.sent(), a.label = 8;
case 8:
return [3, 10];
case 9:
if (i)
throw i.error;
return [7];
case 10:
return [7];
case 11:
return e.complete(), [2];
}
});
});
}
function I(n, e, t, r, i) {
r === void 0 && (r = 0), i === void 0 && (i = !1);
var s = e.schedule(function() {
t(), i ? n.add(this.schedule(null, r)) : this.unsubscribe();
}, r);
if (n.add(s), !i)
return s;
}
function gt(n, e) {
return e === void 0 && (e = 0), E(function(t, r) {
t.subscribe(m(r, function(i) {
return I(r, n, function() {
return r.next(i);
}, e);
}, function() {
return I(r, n, function() {
return r.complete();
}, e);
}, function(i) {
return I(r, n, function() {
return r.error(i);
}, e);
}));
});
}
function mt(n, e) {
return e === void 0 && (e = 0), E(function(t, r) {
r.add(n.schedule(function() {
return t.subscribe(r);
}, e));
});
}
function Sn(n, e) {
return $(n).pipe(mt(e), gt(e));
}
function En(n, e) {
return $(n).pipe(mt(e), gt(e));
}
function xn(n, e) {
return new R(function(t) {
var r = 0;
return e.schedule(function() {
r === n.length ? t.complete() : (t.next(n[r++]), t.closed || this.schedule());
});
});
}
function On(n, e) {
return new R(function(t) {
var r;
return I(t, e, function() {
r = n[dt](), I(t, e, function() {
var i, s, o;
try {
i = r.next(), s = i.value, o = i.done;
} catch (u) {
t.error(u);
return;
}
o ? t.complete() : t.next(s);
}, 0, !0);
}), function() {
return w(r == null ? void 0 : r.return) && r.return();
};
});
}
function wt(n, e) {
if (!n)
throw new Error("Iterable cannot be null");
return new R(function(t) {
I(t, e, function() {
var r = n[Symbol.asyncIterator]();
I(t, e, function() {
r.next().then(function(i) {
i.done ? t.complete() : t.next(i.value);
});
}, 0, !0);
});
});
}
function Rn(n, e) {
return wt(bt(n), e);
}
function $n(n, e) {
if (n != null) {
if (lt(n))
return Sn(n, e);
if (ct(n))
return xn(n, e);
if (at(n))
return En(n, e);
if (ft(n))
return wt(n, e);
if (yt(n))
return On(n, e);
if (pt(n))
return Rn(n, e);
}
throw ht(n);
}
function j(n, e) {
return e ? $n(n, e) : $(n);
}
function ce() {
for (var n = [], e = 0; e < arguments.length; e++)
n[e] = arguments[e];
var t = ue(n);
return j(n, t);
}
var Te = oe(function(n) {
return function() {
n(this), this.name = "EmptyError", this.message = "no elements in sequence";
};
});
function St(n, e) {
var t = typeof e == "object";
return new Promise(function(r, i) {
var s = new ie({
next: function(o) {
r(o), s.unsubscribe();
},
error: i,
complete: function() {
t ? r(e.defaultValue) : i(new Te());
}
});
n.subscribe(s);
});
}
function Et(n) {
return n instanceof Date && !isNaN(n);
}
var xt = oe(function(n) {
return function(t) {
t === void 0 && (t = null), n(this), this.message = "Timeout has occurred", this.name = "TimeoutError", this.info = t;
};
});
function Ot(n, e) {
var t = Et(n) ? { first: n } : typeof n == "number" ? { each: n } : n, r = t.first, i = t.each, s = t.with, o = s === void 0 ? An : s, u = t.scheduler, a = u === void 0 ? e ?? Ae : u, l = t.meta, c = l === void 0 ? null : l;
if (r == null && i == null)
throw new TypeError("No timeout provided.");
return E(function(f, d) {
var y, b, p = null, g = 0, x = function(O) {
b = I(d, a, function() {
try {
y.unsubscribe(), $(o({
meta: c,
lastValue: p,
seen: g
})).subscribe(d);
} catch (le) {
d.error(le);
}
}, O);
};
y = f.subscribe(m(d, function(O) {
b == null || b.unsubscribe(), g++, d.next(p = O), i > 0 && x(i);
}, void 0, void 0, function() {
b != null && b.closed || b == null || b.unsubscribe(), p = null;
})), !g && x(r != null ? typeof r == "number" ? r : +r - a.now() : i);
});
}
function An(n) {
throw new xt(n);
}
function A(n, e) {
return E(function(t, r) {
var i = 0;
t.subscribe(m(r, function(s) {
r.next(n.call(e, s, i++));
}));
});
}
var In = Array.isArray;
function Tn(n, e) {
return In(e) ? n.apply(void 0, N([], D(e))) : n(e);
}
function kn(n) {
return A(function(e) {
return Tn(n, e);
});
}
var Pn = Array.isArray, _n = Object.getPrototypeOf, Cn = Object.prototype, jn = Object.keys;
function Dn(n) {
if (n.length === 1) {
var e = n[0];
if (Pn(e))
return { args: e, keys: null };
if (Nn(e)) {
var t = jn(e);
return {
args: t.map(function(r) {
return e[r];
}),
keys: t
};
}
}
return { args: n, keys: null };
}
function Nn(n) {
return n && typeof n == "object" && _n(n) === Cn;
}
function qn(n, e) {
return n.reduce(function(t, r, i) {
return t[r] = e[i], t;
}, {});
}
function Ln() {
for (var n = [], e = 0; e < arguments.length; e++)
n[e] = arguments[e];
var t = ue(n), r = hn(n), i = Dn(n), s = i.args, o = i.keys;
if (s.length === 0)
return j([], t);
var u = new R(Un(s, t, o ? function(a) {
return qn(o, a);
} : C));
return r ? u.pipe(kn(r)) : u;
}
function Un(n, e, t) {
return t === void 0 && (t = C), function(r) {
ze(e, function() {
for (var i = n.length, s = new Array(i), o = i, u = i, a = function(c) {
ze(e, function() {
var f = j(n[c], e), d = !1;
f.subscribe(m(r, function(y) {
s[c] = y, d || (d = !0, u--), u || r.next(t(s.slice()));
}, function() {
--o || r.complete();
}));
}, r);
}, l = 0; l < i; l++)
a(l);
}, r);
};
}
function ze(n, e, t) {
n ? I(t, n, e) : e();
}
function Mn(n, e, t, r, i, s, o, u) {
var a = [], l = 0, c = 0, f = !1, d = function() {
f && !a.length && !l && e.complete();
}, y = function(p) {
return l < r ? b(p) : a.push(p);
}, b = function(p) {
s && e.next(p), l++;
var g = !1;
$(t(p, c++)).subscribe(m(e, function(x) {
i == null || i(x), s ? y(x) : e.next(x);
}, function() {
g = !0;
}, void 0, function() {
if (g)
try {
l--;
for (var x = function() {
var O = a.shift();
o ? I(e, o, function() {
return b(O);
}) : b(O);
}; a.length && l < r; )
x();
d();
} catch (O) {
e.error(O);
}
}));
};
return n.subscribe(m(e, y, function() {