mongodb-chatbot-ui
Version:
UI React components for the MongoDB Chatbot Framework
1,521 lines (1,512 loc) • 62.9 kB
JavaScript
import { p as ce, j as ye } from "./jsx-runtime.js";
import { u as Oe, c as Ke, a as et, d as tt, U as rt } from "./index2.js";
import { m as nt, U as ot } from "./messageLinks.js";
import { useMemo as at, useState as Re, useRef as it, startTransition as st } from "react";
import { r as Je, a as ct, p as ut, b as ft } from "./index3.js";
import { c as Ue, S as lt, a as pt, C as dt } from "./ConversationStateProvider2.js";
import { c as ht, a as gt } from "./utils.js";
import { useConversationStateContext as yt } from "./useConversationStateContext.js";
import { L as mt } from "./LinkDataProvider.js";
import { C as vt } from "./ChatbotProvider.js";
import { H as bt } from "./HotkeyContext.js";
async function wt(c, o) {
const g = c.getReader();
let f;
for (; !(f = await g.read()).done; )
o(f.value);
}
function Et(c) {
let o, g, f, S = !1;
return function(I) {
o === void 0 ? (o = I, g = 0, f = -1) : o = Ot(o, I);
const M = o.length;
let G = 0;
for (; g < M; ) {
S && (o[g] === 10 && (G = ++g), S = !1);
let $ = -1;
for (; g < M && $ === -1; ++g)
switch (o[g]) {
case 58:
f === -1 && (f = g - G);
break;
case 13:
S = !0;
case 10:
$ = g;
break;
}
if ($ === -1)
break;
c(o.subarray(G, $), f), G = g, f = -1;
}
G === M ? o = void 0 : G !== 0 && (o = o.subarray(G), g -= G);
};
}
function St(c, o, g) {
let f = Fe();
const S = new TextDecoder();
return function(I, M) {
if (I.length === 0)
g == null || g(f), f = Fe();
else if (M > 0) {
const G = S.decode(I.subarray(0, M)), $ = M + (I[M + 1] === 32 ? 2 : 1), Y = S.decode(I.subarray($));
switch (G) {
case "data":
f.data = f.data ? f.data + `
` + Y : Y;
break;
case "event":
f.event = Y;
break;
case "id":
c(f.id = Y);
break;
case "retry":
const A = parseInt(Y, 10);
isNaN(A) || o(f.retry = A);
break;
}
}
};
}
function Ot(c, o) {
const g = new Uint8Array(c.length + o.length);
return g.set(c), g.set(o, c.length), g;
}
function Fe() {
return {
data: "",
event: "",
id: "",
retry: void 0
};
}
var jt = globalThis && globalThis.__rest || function(c, o) {
var g = {};
for (var f in c)
Object.prototype.hasOwnProperty.call(c, f) && o.indexOf(f) < 0 && (g[f] = c[f]);
if (c != null && typeof Object.getOwnPropertySymbols == "function")
for (var S = 0, f = Object.getOwnPropertySymbols(c); S < f.length; S++)
o.indexOf(f[S]) < 0 && Object.prototype.propertyIsEnumerable.call(c, f[S]) && (g[f[S]] = c[f[S]]);
return g;
};
const De = "text/event-stream", Rt = 1e3, Le = "last-event-id";
function It(c, o) {
var { signal: g, headers: f, onopen: S, onmessage: _, onclose: I, onerror: M, openWhenHidden: G, fetch: $ } = o, Y = jt(o, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
return new Promise((A, j) => {
const C = Object.assign({}, f);
C.accept || (C.accept = De);
let V;
function q() {
V.abort(), document.hidden || u();
}
G || document.addEventListener("visibilitychange", q);
let T = Rt, N = 0;
function F() {
document.removeEventListener("visibilitychange", q), window.clearTimeout(N), V.abort();
}
g == null || g.addEventListener("abort", () => {
F(), A();
});
const re = $ ?? window.fetch, Z = S ?? qt;
async function u() {
var s;
V = new AbortController();
try {
const d = await re(c, Object.assign(Object.assign({}, Y), { headers: C, signal: V.signal }));
await Z(d), await wt(d.body, Et(St((m) => {
m ? C[Le] = m : delete C[Le];
}, (m) => {
T = m;
}, _))), I == null || I(), F(), A();
} catch (d) {
if (!V.signal.aborted)
try {
const m = (s = M == null ? void 0 : M(d)) !== null && s !== void 0 ? s : T;
window.clearTimeout(N), N = window.setTimeout(u, m);
} catch (m) {
F(), j(m);
}
}
}
u();
});
}
function qt(c) {
const o = c.headers.get("content-type");
if (!(o != null && o.startsWith(De)))
throw new Error(`Expected content-type to be ${De}, Actual: ${o}`);
}
var Ie = { exports: {} }, qe = {}, Be;
function Xe() {
if (Be)
return qe;
Be = 1;
function c(u) {
"@babel/helpers - typeof";
return c = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(s) {
return typeof s;
} : function(s) {
return s && typeof Symbol == "function" && s.constructor === Symbol && s !== Symbol.prototype ? "symbol" : typeof s;
}, c(u);
}
function o(u, s) {
for (var d = 0; d < s.length; d++) {
var m = s[d];
m.enumerable = m.enumerable || !1, m.configurable = !0, "value" in m && (m.writable = !0), Object.defineProperty(u, f(m.key), m);
}
}
function g(u, s, d) {
return s && o(u.prototype, s), d && o(u, d), Object.defineProperty(u, "prototype", { writable: !1 }), u;
}
function f(u) {
var s = S(u, "string");
return c(s) === "symbol" ? s : String(s);
}
function S(u, s) {
if (c(u) !== "object" || u === null)
return u;
var d = u[Symbol.toPrimitive];
if (d !== void 0) {
var m = d.call(u, s || "default");
if (c(m) !== "object")
return m;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (s === "string" ? String : Number)(u);
}
function _(u, s) {
if (!(u instanceof s))
throw new TypeError("Cannot call a class as a function");
}
function I(u, s) {
if (typeof s != "function" && s !== null)
throw new TypeError("Super expression must either be null or a function");
u.prototype = Object.create(s && s.prototype, { constructor: { value: u, writable: !0, configurable: !0 } }), Object.defineProperty(u, "prototype", { writable: !1 }), s && M(u, s);
}
function M(u, s) {
return M = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(m, B) {
return m.__proto__ = B, m;
}, M(u, s);
}
function G(u) {
var s = A();
return function() {
var m = j(u), B;
if (s) {
var y = j(this).constructor;
B = Reflect.construct(m, arguments, y);
} else
B = m.apply(this, arguments);
return $(this, B);
};
}
function $(u, s) {
if (s && (c(s) === "object" || typeof s == "function"))
return s;
if (s !== void 0)
throw new TypeError("Derived constructors may only return object or undefined");
return Y(u);
}
function Y(u) {
if (u === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return u;
}
function A() {
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
return !1;
if (typeof Proxy == "function")
return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch {
return !1;
}
}
function j(u) {
return j = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(d) {
return d.__proto__ || Object.getPrototypeOf(d);
}, j(u);
}
var C = {}, V, q;
function T(u, s, d) {
d || (d = Error);
function m(y, X, x) {
return typeof s == "string" ? s : s(y, X, x);
}
var B = /* @__PURE__ */ function(y) {
I(x, y);
var X = G(x);
function x(te, pe, se) {
var oe;
return _(this, x), oe = X.call(this, m(te, pe, se)), oe.code = u, oe;
}
return g(x);
}(d);
C[u] = B;
}
function N(u, s) {
if (Array.isArray(u)) {
var d = u.length;
return u = u.map(function(m) {
return String(m);
}), d > 2 ? "one of ".concat(s, " ").concat(u.slice(0, d - 1).join(", "), ", or ") + u[d - 1] : d === 2 ? "one of ".concat(s, " ").concat(u[0], " or ").concat(u[1]) : "of ".concat(s, " ").concat(u[0]);
} else
return "of ".concat(s, " ").concat(String(u));
}
function F(u, s, d) {
return u.substr(!d || d < 0 ? 0 : +d, s.length) === s;
}
function re(u, s, d) {
return (d === void 0 || d > u.length) && (d = u.length), u.substring(d - s.length, d) === s;
}
function Z(u, s, d) {
return typeof d != "number" && (d = 0), d + s.length > u.length ? !1 : u.indexOf(s, d) !== -1;
}
return T("ERR_AMBIGUOUS_ARGUMENT", 'The "%s" argument is ambiguous. %s', TypeError), T("ERR_INVALID_ARG_TYPE", function(u, s, d) {
V === void 0 && (V = Ce()), V(typeof u == "string", "'name' must be a string");
var m;
typeof s == "string" && F(s, "not ") ? (m = "must not be", s = s.replace(/^not /, "")) : m = "must be";
var B;
if (re(u, " argument"))
B = "The ".concat(u, " ").concat(m, " ").concat(N(s, "type"));
else {
var y = Z(u, ".") ? "property" : "argument";
B = 'The "'.concat(u, '" ').concat(y, " ").concat(m, " ").concat(N(s, "type"));
}
return B += ". Received type ".concat(c(d)), B;
}, TypeError), T("ERR_INVALID_ARG_VALUE", function(u, s) {
var d = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "is invalid";
q === void 0 && (q = Oe);
var m = q.inspect(s);
return m.length > 128 && (m = "".concat(m.slice(0, 128), "...")), "The argument '".concat(u, "' ").concat(d, ". Received ").concat(m);
}, TypeError), T("ERR_INVALID_RETURN_VALUE", function(u, s, d) {
var m;
return d && d.constructor && d.constructor.name ? m = "instance of ".concat(d.constructor.name) : m = "type ".concat(c(d)), "Expected ".concat(u, ' to be returned from the "').concat(s, '"') + " function but got ".concat(m, ".");
}, TypeError), T("ERR_MISSING_ARGS", function() {
for (var u = arguments.length, s = new Array(u), d = 0; d < u; d++)
s[d] = arguments[d];
V === void 0 && (V = Ce()), V(s.length > 0, "At least one arg needs to be specified");
var m = "The ", B = s.length;
switch (s = s.map(function(y) {
return '"'.concat(y, '"');
}), B) {
case 1:
m += "".concat(s[0], " argument");
break;
case 2:
m += "".concat(s[0], " and ").concat(s[1], " arguments");
break;
default:
m += s.slice(0, B - 1).join(", "), m += ", and ".concat(s[B - 1], " arguments");
break;
}
return "".concat(m, " must be specified");
}, TypeError), qe.codes = C, qe;
}
var Ae, $e;
function At() {
if ($e)
return Ae;
$e = 1;
function c(l, p) {
var w = Object.keys(l);
if (Object.getOwnPropertySymbols) {
var v = Object.getOwnPropertySymbols(l);
p && (v = v.filter(function(P) {
return Object.getOwnPropertyDescriptor(l, P).enumerable;
})), w.push.apply(w, v);
}
return w;
}
function o(l) {
for (var p = 1; p < arguments.length; p++) {
var w = arguments[p] != null ? arguments[p] : {};
p % 2 ? c(Object(w), !0).forEach(function(v) {
g(l, v, w[v]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(l, Object.getOwnPropertyDescriptors(w)) : c(Object(w)).forEach(function(v) {
Object.defineProperty(l, v, Object.getOwnPropertyDescriptor(w, v));
});
}
return l;
}
function g(l, p, w) {
return p = I(p), p in l ? Object.defineProperty(l, p, { value: w, enumerable: !0, configurable: !0, writable: !0 }) : l[p] = w, l;
}
function f(l, p) {
if (!(l instanceof p))
throw new TypeError("Cannot call a class as a function");
}
function S(l, p) {
for (var w = 0; w < p.length; w++) {
var v = p[w];
v.enumerable = v.enumerable || !1, v.configurable = !0, "value" in v && (v.writable = !0), Object.defineProperty(l, I(v.key), v);
}
}
function _(l, p, w) {
return p && S(l.prototype, p), w && S(l, w), Object.defineProperty(l, "prototype", { writable: !1 }), l;
}
function I(l) {
var p = M(l, "string");
return F(p) === "symbol" ? p : String(p);
}
function M(l, p) {
if (F(l) !== "object" || l === null)
return l;
var w = l[Symbol.toPrimitive];
if (w !== void 0) {
var v = w.call(l, p || "default");
if (F(v) !== "object")
return v;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (p === "string" ? String : Number)(l);
}
function G(l, p) {
if (typeof p != "function" && p !== null)
throw new TypeError("Super expression must either be null or a function");
l.prototype = Object.create(p && p.prototype, { constructor: { value: l, writable: !0, configurable: !0 } }), Object.defineProperty(l, "prototype", { writable: !1 }), p && T(l, p);
}
function $(l) {
var p = V();
return function() {
var v = N(l), P;
if (p) {
var k = N(this).constructor;
P = Reflect.construct(v, arguments, k);
} else
P = v.apply(this, arguments);
return Y(this, P);
};
}
function Y(l, p) {
if (p && (F(p) === "object" || typeof p == "function"))
return p;
if (p !== void 0)
throw new TypeError("Derived constructors may only return object or undefined");
return A(l);
}
function A(l) {
if (l === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return l;
}
function j(l) {
var p = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
return j = function(v) {
if (v === null || !q(v))
return v;
if (typeof v != "function")
throw new TypeError("Super expression must either be null or a function");
if (typeof p < "u") {
if (p.has(v))
return p.get(v);
p.set(v, P);
}
function P() {
return C(v, arguments, N(this).constructor);
}
return P.prototype = Object.create(v.prototype, { constructor: { value: P, enumerable: !1, writable: !0, configurable: !0 } }), T(P, v);
}, j(l);
}
function C(l, p, w) {
return V() ? C = Reflect.construct.bind() : C = function(P, k, Q) {
var z = [null];
z.push.apply(z, k);
var a = Function.bind.apply(P, z), e = new a();
return Q && T(e, Q.prototype), e;
}, C.apply(null, arguments);
}
function V() {
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
return !1;
if (typeof Proxy == "function")
return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch {
return !1;
}
}
function q(l) {
return Function.toString.call(l).indexOf("[native code]") !== -1;
}
function T(l, p) {
return T = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(v, P) {
return v.__proto__ = P, v;
}, T(l, p);
}
function N(l) {
return N = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(w) {
return w.__proto__ || Object.getPrototypeOf(w);
}, N(l);
}
function F(l) {
"@babel/helpers - typeof";
return F = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(p) {
return typeof p;
} : function(p) {
return p && typeof Symbol == "function" && p.constructor === Symbol && p !== Symbol.prototype ? "symbol" : typeof p;
}, F(l);
}
var re = Oe, Z = re.inspect, u = Xe(), s = u.codes.ERR_INVALID_ARG_TYPE;
function d(l, p, w) {
return (w === void 0 || w > l.length) && (w = l.length), l.substring(w - p.length, w) === p;
}
function m(l, p) {
if (p = Math.floor(p), l.length == 0 || p == 0)
return "";
var w = l.length * p;
for (p = Math.floor(Math.log(p) / Math.log(2)); p; )
l += l, p--;
return l += l.substring(0, w - l.length), l;
}
var B = "", y = "", X = "", x = "", te = {
deepStrictEqual: "Expected values to be strictly deep-equal:",
strictEqual: "Expected values to be strictly equal:",
strictEqualObject: 'Expected "actual" to be reference-equal to "expected":',
deepEqual: "Expected values to be loosely deep-equal:",
equal: "Expected values to be loosely equal:",
notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:',
notStrictEqual: 'Expected "actual" to be strictly unequal to:',
notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":',
notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:',
notEqual: 'Expected "actual" to be loosely unequal to:',
notIdentical: "Values identical but not reference-equal:"
}, pe = 10;
function se(l) {
var p = Object.keys(l), w = Object.create(Object.getPrototypeOf(l));
return p.forEach(function(v) {
w[v] = l[v];
}), Object.defineProperty(w, "message", {
value: l.message
}), w;
}
function oe(l) {
return Z(l, {
compact: !1,
customInspect: !1,
depth: 1e3,
maxArrayLength: 1 / 0,
// Assert compares only enumerable properties (with a few exceptions).
showHidden: !1,
// Having a long line as error is better than wrapping the line for
// comparison for now.
// TODO(BridgeAR): `breakLength` should be limited as soon as soon as we
// have meta information about the inspected properties (i.e., know where
// in what line the property starts and ends).
breakLength: 1 / 0,
// Assert does not detect proxies currently.
showProxy: !1,
sorted: !0,
// Inspect getters as we also check them when comparing entries.
getters: !0
});
}
function me(l, p, w) {
var v = "", P = "", k = 0, Q = "", z = !1, a = oe(l), e = a.split(`
`), r = oe(p).split(`
`), i = 0, b = "";
if (w === "strictEqual" && F(l) === "object" && F(p) === "object" && l !== null && p !== null && (w = "strictEqualObject"), e.length === 1 && r.length === 1 && e[0] !== r[0]) {
var O = e[0].length + r[0].length;
if (O <= pe) {
if ((F(l) !== "object" || l === null) && (F(p) !== "object" || p === null) && (l !== 0 || p !== 0))
return "".concat(te[w], `
`) + "".concat(e[0], " !== ").concat(r[0], `
`);
} else if (w !== "strictEqualObject") {
var U = ce.stderr && ce.stderr.isTTY ? ce.stderr.columns : 80;
if (O < U) {
for (; e[0][i] === r[0][i]; )
i++;
i > 2 && (b = `
`.concat(m(" ", i), "^"), i = 0);
}
}
}
for (var J = e[e.length - 1], K = r[r.length - 1]; J === K && (i++ < 2 ? Q = `
`.concat(J).concat(Q) : v = J, e.pop(), r.pop(), !(e.length === 0 || r.length === 0)); )
J = e[e.length - 1], K = r[r.length - 1];
var ue = Math.max(e.length, r.length);
if (ue === 0) {
var he = a.split(`
`);
if (he.length > 30)
for (he[26] = "".concat(B, "...").concat(x); he.length > 27; )
he.pop();
return "".concat(te.notIdentical, `
`).concat(he.join(`
`), `
`);
}
i > 3 && (Q = `
`.concat(B, "...").concat(x).concat(Q), z = !0), v !== "" && (Q = `
`.concat(v).concat(Q), v = "");
var ae = 0, be = te[w] + `
`.concat(y, "+ actual").concat(x, " ").concat(X, "- expected").concat(x), je = " ".concat(B, "...").concat(x, " Lines skipped");
for (i = 0; i < ue; i++) {
var ie = i - k;
if (e.length < i + 1)
ie > 1 && i > 2 && (ie > 4 ? (P += `
`.concat(B, "...").concat(x), z = !0) : ie > 3 && (P += `
`.concat(r[i - 2]), ae++), P += `
`.concat(r[i - 1]), ae++), k = i, v += `
`.concat(X, "-").concat(x, " ").concat(r[i]), ae++;
else if (r.length < i + 1)
ie > 1 && i > 2 && (ie > 4 ? (P += `
`.concat(B, "...").concat(x), z = !0) : ie > 3 && (P += `
`.concat(e[i - 2]), ae++), P += `
`.concat(e[i - 1]), ae++), k = i, P += `
`.concat(y, "+").concat(x, " ").concat(e[i]), ae++;
else {
var ge = r[i], fe = e[i], t = fe !== ge && (!d(fe, ",") || fe.slice(0, -1) !== ge);
t && d(ge, ",") && ge.slice(0, -1) === fe && (t = !1, fe += ","), t ? (ie > 1 && i > 2 && (ie > 4 ? (P += `
`.concat(B, "...").concat(x), z = !0) : ie > 3 && (P += `
`.concat(e[i - 2]), ae++), P += `
`.concat(e[i - 1]), ae++), k = i, P += `
`.concat(y, "+").concat(x, " ").concat(fe), v += `
`.concat(X, "-").concat(x, " ").concat(ge), ae += 2) : (P += v, v = "", (ie === 1 || i === 0) && (P += `
`.concat(fe), ae++));
}
if (ae > 20 && i < ue - 2)
return "".concat(be).concat(je, `
`).concat(P, `
`).concat(B, "...").concat(x).concat(v, `
`) + "".concat(B, "...").concat(x);
}
return "".concat(be).concat(z ? je : "", `
`).concat(P).concat(v).concat(Q).concat(b);
}
var de = /* @__PURE__ */ function(l, p) {
G(v, l);
var w = $(v);
function v(P) {
var k;
if (f(this, v), F(P) !== "object" || P === null)
throw new s("options", "Object", P);
var Q = P.message, z = P.operator, a = P.stackStartFn, e = P.actual, r = P.expected, i = Error.stackTraceLimit;
if (Error.stackTraceLimit = 0, Q != null)
k = w.call(this, String(Q));
else if (ce.stderr && ce.stderr.isTTY && (ce.stderr && ce.stderr.getColorDepth && ce.stderr.getColorDepth() !== 1 ? (B = "\x1B[34m", y = "\x1B[32m", x = "\x1B[39m", X = "\x1B[31m") : (B = "", y = "", x = "", X = "")), F(e) === "object" && e !== null && F(r) === "object" && r !== null && "stack" in e && e instanceof Error && "stack" in r && r instanceof Error && (e = se(e), r = se(r)), z === "deepStrictEqual" || z === "strictEqual")
k = w.call(this, me(e, r, z));
else if (z === "notDeepStrictEqual" || z === "notStrictEqual") {
var b = te[z], O = oe(e).split(`
`);
if (z === "notStrictEqual" && F(e) === "object" && e !== null && (b = te.notStrictEqualObject), O.length > 30)
for (O[26] = "".concat(B, "...").concat(x); O.length > 27; )
O.pop();
O.length === 1 ? k = w.call(this, "".concat(b, " ").concat(O[0])) : k = w.call(this, "".concat(b, `
`).concat(O.join(`
`), `
`));
} else {
var U = oe(e), J = "", K = te[z];
z === "notDeepEqual" || z === "notEqual" ? (U = "".concat(te[z], `
`).concat(U), U.length > 1024 && (U = "".concat(U.slice(0, 1021), "..."))) : (J = "".concat(oe(r)), U.length > 512 && (U = "".concat(U.slice(0, 509), "...")), J.length > 512 && (J = "".concat(J.slice(0, 509), "...")), z === "deepEqual" || z === "equal" ? U = "".concat(K, `
`).concat(U, `
should equal
`) : J = " ".concat(z, " ").concat(J)), k = w.call(this, "".concat(U).concat(J));
}
return Error.stackTraceLimit = i, k.generatedMessage = !Q, Object.defineProperty(A(k), "name", {
value: "AssertionError [ERR_ASSERTION]",
enumerable: !1,
writable: !0,
configurable: !0
}), k.code = "ERR_ASSERTION", k.actual = e, k.expected = r, k.operator = z, Error.captureStackTrace && Error.captureStackTrace(A(k), a), k.stack, k.name = "AssertionError", Y(k);
}
return _(v, [{
key: "toString",
value: function() {
return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message);
}
}, {
key: p,
value: function(k, Q) {
return Z(this, o(o({}, Q), {}, {
customInspect: !1,
depth: 0
}));
}
}]), v;
}(/* @__PURE__ */ j(Error), Z.custom);
return Ae = de, Ae;
}
var Pe, Ve;
function Qe() {
return Ve || (Ve = 1, Pe = function(o) {
return o !== o;
}), Pe;
}
var Ne, Ge;
function Ze() {
if (Ge)
return Ne;
Ge = 1;
var c = Qe();
return Ne = function() {
return Number.isNaN && Number.isNaN(NaN) && !Number.isNaN("a") ? Number.isNaN : c;
}, Ne;
}
var Te, ke;
function Pt() {
if (ke)
return Te;
ke = 1;
var c = Je(), o = Ze();
return Te = function() {
var f = o();
return c(Number, { isNaN: f }, {
isNaN: function() {
return Number.isNaN !== f;
}
}), f;
}, Te;
}
var xe, He;
function Nt() {
if (He)
return xe;
He = 1;
var c = Ke, o = Je(), g = Qe(), f = Ze(), S = Pt(), _ = c(f(), Number);
return o(_, {
getPolyfill: f,
implementation: g,
shim: S
}), xe = _, xe;
}
var _e, We;
function Tt() {
if (We)
return _e;
We = 1;
function c(t, n) {
return _(t) || S(t, n) || g(t, n) || o();
}
function o() {
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function g(t, n) {
if (t) {
if (typeof t == "string")
return f(t, n);
var h = Object.prototype.toString.call(t).slice(8, -1);
if (h === "Object" && t.constructor && (h = t.constructor.name), h === "Map" || h === "Set")
return Array.from(t);
if (h === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))
return f(t, n);
}
}
function f(t, n) {
(n == null || n > t.length) && (n = t.length);
for (var h = 0, E = new Array(n); h < n; h++)
E[h] = t[h];
return E;
}
function S(t, n) {
var h = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
if (h != null) {
var E, R, L, D, H = [], W = !0, ee = !1;
try {
if (L = (h = h.call(t)).next, n === 0) {
if (Object(h) !== h)
return;
W = !1;
} else
for (; !(W = (E = L.call(h)).done) && (H.push(E.value), H.length !== n); W = !0)
;
} catch (ne) {
ee = !0, R = ne;
} finally {
try {
if (!W && h.return != null && (D = h.return(), Object(D) !== D))
return;
} finally {
if (ee)
throw R;
}
}
return H;
}
}
function _(t) {
if (Array.isArray(t))
return t;
}
function I(t) {
"@babel/helpers - typeof";
return I = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
return typeof n;
} : function(n) {
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
}, I(t);
}
var M = /a/g.flags !== void 0, G = function(n) {
var h = [];
return n.forEach(function(E) {
return h.push(E);
}), h;
}, $ = function(n) {
var h = [];
return n.forEach(function(E, R) {
return h.push([R, E]);
}), h;
}, Y = Object.is ? Object.is : ct(), A = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function() {
return [];
}, j = Number.isNaN ? Number.isNaN : Nt();
function C(t) {
return t.call.bind(t);
}
var V = C(Object.prototype.hasOwnProperty), q = C(Object.prototype.propertyIsEnumerable), T = C(Object.prototype.toString), N = Oe.types, F = N.isAnyArrayBuffer, re = N.isArrayBufferView, Z = N.isDate, u = N.isMap, s = N.isRegExp, d = N.isSet, m = N.isNativeError, B = N.isBoxedPrimitive, y = N.isNumberObject, X = N.isStringObject, x = N.isBooleanObject, te = N.isBigIntObject, pe = N.isSymbolObject, se = N.isFloat32Array, oe = N.isFloat64Array;
function me(t) {
if (t.length === 0 || t.length > 10)
return !0;
for (var n = 0; n < t.length; n++) {
var h = t.charCodeAt(n);
if (h < 48 || h > 57)
return !0;
}
return t.length === 10 && t >= Math.pow(2, 32);
}
function de(t) {
return Object.keys(t).filter(me).concat(A(t).filter(Object.prototype.propertyIsEnumerable.bind(t)));
}
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
function l(t, n) {
if (t === n)
return 0;
for (var h = t.length, E = n.length, R = 0, L = Math.min(h, E); R < L; ++R)
if (t[R] !== n[R]) {
h = t[R], E = n[R];
break;
}
return h < E ? -1 : E < h ? 1 : 0;
}
var p = !0, w = !1, v = 0, P = 1, k = 2, Q = 3;
function z(t, n) {
return M ? t.source === n.source && t.flags === n.flags : RegExp.prototype.toString.call(t) === RegExp.prototype.toString.call(n);
}
function a(t, n) {
if (t.byteLength !== n.byteLength)
return !1;
for (var h = 0; h < t.byteLength; h++)
if (t[h] !== n[h])
return !1;
return !0;
}
function e(t, n) {
return t.byteLength !== n.byteLength ? !1 : l(new Uint8Array(t.buffer, t.byteOffset, t.byteLength), new Uint8Array(n.buffer, n.byteOffset, n.byteLength)) === 0;
}
function r(t, n) {
return t.byteLength === n.byteLength && l(new Uint8Array(t), new Uint8Array(n)) === 0;
}
function i(t, n) {
return y(t) ? y(n) && Y(Number.prototype.valueOf.call(t), Number.prototype.valueOf.call(n)) : X(t) ? X(n) && String.prototype.valueOf.call(t) === String.prototype.valueOf.call(n) : x(t) ? x(n) && Boolean.prototype.valueOf.call(t) === Boolean.prototype.valueOf.call(n) : te(t) ? te(n) && BigInt.prototype.valueOf.call(t) === BigInt.prototype.valueOf.call(n) : pe(n) && Symbol.prototype.valueOf.call(t) === Symbol.prototype.valueOf.call(n);
}
function b(t, n, h, E) {
if (t === n)
return t !== 0 ? !0 : h ? Y(t, n) : !0;
if (h) {
if (I(t) !== "object")
return typeof t == "number" && j(t) && j(n);
if (I(n) !== "object" || t === null || n === null || Object.getPrototypeOf(t) !== Object.getPrototypeOf(n))
return !1;
} else {
if (t === null || I(t) !== "object")
return n === null || I(n) !== "object" ? t == n : !1;
if (n === null || I(n) !== "object")
return !1;
}
var R = T(t), L = T(n);
if (R !== L)
return !1;
if (Array.isArray(t)) {
if (t.length !== n.length)
return !1;
var D = de(t), H = de(n);
return D.length !== H.length ? !1 : U(t, n, h, E, P, D);
}
if (R === "[object Object]" && (!u(t) && u(n) || !d(t) && d(n)))
return !1;
if (Z(t)) {
if (!Z(n) || Date.prototype.getTime.call(t) !== Date.prototype.getTime.call(n))
return !1;
} else if (s(t)) {
if (!s(n) || !z(t, n))
return !1;
} else if (m(t) || t instanceof Error) {
if (t.message !== n.message || t.name !== n.name)
return !1;
} else if (re(t)) {
if (!h && (se(t) || oe(t))) {
if (!a(t, n))
return !1;
} else if (!e(t, n))
return !1;
var W = de(t), ee = de(n);
return W.length !== ee.length ? !1 : U(t, n, h, E, v, W);
} else {
if (d(t))
return !d(n) || t.size !== n.size ? !1 : U(t, n, h, E, k);
if (u(t))
return !u(n) || t.size !== n.size ? !1 : U(t, n, h, E, Q);
if (F(t)) {
if (!r(t, n))
return !1;
} else if (B(t) && !i(t, n))
return !1;
}
return U(t, n, h, E, v);
}
function O(t, n) {
return n.filter(function(h) {
return q(t, h);
});
}
function U(t, n, h, E, R, L) {
if (arguments.length === 5) {
L = Object.keys(t);
var D = Object.keys(n);
if (L.length !== D.length)
return !1;
}
for (var H = 0; H < L.length; H++)
if (!V(n, L[H]))
return !1;
if (h && arguments.length === 5) {
var W = A(t);
if (W.length !== 0) {
var ee = 0;
for (H = 0; H < W.length; H++) {
var ne = W[H];
if (q(t, ne)) {
if (!q(n, ne))
return !1;
L.push(ne), ee++;
} else if (q(n, ne))
return !1;
}
var we = A(n);
if (W.length !== we.length && O(n, we).length !== ee)
return !1;
} else {
var ve = A(n);
if (ve.length !== 0 && O(n, ve).length !== 0)
return !1;
}
}
if (L.length === 0 && (R === v || R === P && t.length === 0 || t.size === 0))
return !0;
if (E === void 0)
E = {
val1: /* @__PURE__ */ new Map(),
val2: /* @__PURE__ */ new Map(),
position: 0
};
else {
var Ee = E.val1.get(t);
if (Ee !== void 0) {
var le = E.val2.get(n);
if (le !== void 0)
return Ee === le;
}
E.position++;
}
E.val1.set(t, E.position), E.val2.set(n, E.position);
var Se = ie(t, n, h, L, E, R);
return E.val1.delete(t), E.val2.delete(n), Se;
}
function J(t, n, h, E) {
for (var R = G(t), L = 0; L < R.length; L++) {
var D = R[L];
if (b(n, D, h, E))
return t.delete(D), !0;
}
return !1;
}
function K(t) {
switch (I(t)) {
case "undefined":
return null;
case "object":
return;
case "symbol":
return !1;
case "string":
t = +t;
case "number":
if (j(t))
return !1;
}
return !0;
}
function ue(t, n, h) {
var E = K(h);
return E ?? (n.has(E) && !t.has(E));
}
function he(t, n, h, E, R) {
var L = K(h);
if (L != null)
return L;
var D = n.get(L);
return D === void 0 && !n.has(L) || !b(E, D, !1, R) ? !1 : !t.has(L) && b(E, D, !1, R);
}
function ae(t, n, h, E) {
for (var R = null, L = G(t), D = 0; D < L.length; D++) {
var H = L[D];
if (I(H) === "object" && H !== null)
R === null && (R = /* @__PURE__ */ new Set()), R.add(H);
else if (!n.has(H)) {
if (h || !ue(t, n, H))
return !1;
R === null && (R = /* @__PURE__ */ new Set()), R.add(H);
}
}
if (R !== null) {
for (var W = G(n), ee = 0; ee < W.length; ee++) {
var ne = W[ee];
if (I(ne) === "object" && ne !== null) {
if (!J(R, ne, h, E))
return !1;
} else if (!h && !t.has(ne) && !J(R, ne, h, E))
return !1;
}
return R.size === 0;
}
return !0;
}
function be(t, n, h, E, R, L) {
for (var D = G(t), H = 0; H < D.length; H++) {
var W = D[H];
if (b(h, W, R, L) && b(E, n.get(W), R, L))
return t.delete(W), !0;
}
return !1;
}
function je(t, n, h, E) {
for (var R = null, L = $(t), D = 0; D < L.length; D++) {
var H = c(L[D], 2), W = H[0], ee = H[1];
if (I(W) === "object" && W !== null)
R === null && (R = /* @__PURE__ */ new Set()), R.add(W);
else {
var ne = n.get(W);
if (ne === void 0 && !n.has(W) || !b(ee, ne, h, E)) {
if (h || !he(t, n, W, ee, E))
return !1;
R === null && (R = /* @__PURE__ */ new Set()), R.add(W);
}
}
}
if (R !== null) {
for (var we = $(n), ve = 0; ve < we.length; ve++) {
var Ee = c(we[ve], 2), le = Ee[0], Se = Ee[1];
if (I(le) === "object" && le !== null) {
if (!be(R, t, le, Se, h, E))
return !1;
} else if (!h && (!t.has(le) || !b(t.get(le), Se, !1, E)) && !be(R, t, le, Se, !1, E))
return !1;
}
return R.size === 0;
}
return !0;
}
function ie(t, n, h, E, R, L) {
var D = 0;
if (L === k) {
if (!ae(t, n, h, R))
return !1;
} else if (L === Q) {
if (!je(t, n, h, R))
return !1;
} else if (L === P)
for (; D < t.length; D++)
if (V(t, D)) {
if (!V(n, D) || !b(t[D], n[D], h, R))
return !1;
} else {
if (V(n, D))
return !1;
for (var H = Object.keys(t); D < H.length; D++) {
var W = H[D];
if (!V(n, W) || !b(t[W], n[W], h, R))
return !1;
}
return H.length === Object.keys(n).length;
}
for (D = 0; D < E.length; D++) {
var ee = E[D];
if (!b(t[ee], n[ee], h, R))
return !1;
}
return !0;
}
function ge(t, n) {
return b(t, n, w);
}
function fe(t, n) {
return b(t, n, p);
}
return _e = {
isDeepEqual: ge,
isDeepStrictEqual: fe
}, _e;
}
var ze;
function Ce() {
if (ze)
return Ie.exports;
ze = 1;
function c(a) {
"@babel/helpers - typeof";
return c = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
return typeof e;
} : function(e) {
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, c(a);
}
function o(a, e) {
for (var r = 0; r < e.length; r++) {
var i = e[r];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(a, f(i.key), i);
}
}
function g(a, e, r) {
return e && o(a.prototype, e), r && o(a, r), Object.defineProperty(a, "prototype", { writable: !1 }), a;
}
function f(a) {
var e = S(a, "string");
return c(e) === "symbol" ? e : String(e);
}
function S(a, e) {
if (c(a) !== "object" || a === null)
return a;
var r = a[Symbol.toPrimitive];
if (r !== void 0) {
var i = r.call(a, e || "default");
if (c(i) !== "object")
return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (e === "string" ? String : Number)(a);
}
function _(a, e) {
if (!(a instanceof e))
throw new TypeError("Cannot call a class as a function");
}
var I = Xe(), M = I.codes, G = M.ERR_AMBIGUOUS_ARGUMENT, $ = M.ERR_INVALID_ARG_TYPE, Y = M.ERR_INVALID_ARG_VALUE, A = M.ERR_INVALID_RETURN_VALUE, j = M.ERR_MISSING_ARGS, C = At(), V = Oe, q = V.inspect, T = Oe.types, N = T.isPromise, F = T.isRegExp, re = ut(), Z = ft(), u = et("RegExp.prototype.test"), s, d;
function m() {
var a = Tt();
s = a.isDeepEqual, d = a.isDeepStrictEqual;
}
var B = !1, y = Ie.exports = se, X = {};
function x(a) {
throw a.message instanceof Error ? a.message : new C(a);
}
function te(a, e, r, i, b) {
var O = arguments.length, U;
if (O === 0)
U = "Failed";
else if (O === 1)
r = a, a = void 0;
else {
if (B === !1) {
B = !0;
var J = ce.emitWarning ? ce.emitWarning : console.warn.bind(console);
J("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.", "DeprecationWarning", "DEP0094");
}
O === 2 && (i = "!=");
}
if (r instanceof Error)
throw r;
var K = {
actual: a,
expected: e,
operator: i === void 0 ? "fail" : i,
stackStartFn: b || te
};
r !== void 0 && (K.message = r);
var ue = new C(K);
throw U && (ue.message = U, ue.generatedMessage = !0), ue;
}
y.fail = te, y.AssertionError = C;
function pe(a, e, r, i) {
if (!r) {
var b = !1;
if (e === 0)
b = !0, i = "No value argument passed to `assert.ok()`";
else if (i instanceof Error)
throw i;
var O = new C({
actual: r,
expected: !0,
message: i,
operator: "==",
stackStartFn: a
});
throw O.generatedMessage = b, O;
}
}
function se() {
for (var a = arguments.length, e = new Array(a), r = 0; r < a; r++)
e[r] = arguments[r];
pe.apply(void 0, [se, e.length].concat(e));
}
y.ok = se, y.equal = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
e != r && x({
actual: e,
expected: r,
message: i,
operator: "==",
stackStartFn: a
});
}, y.notEqual = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
e == r && x({
actual: e,
expected: r,
message: i,
operator: "!=",
stackStartFn: a
});
}, y.deepEqual = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
s === void 0 && m(), s(e, r) || x({
actual: e,
expected: r,
message: i,
operator: "deepEqual",
stackStartFn: a
});
}, y.notDeepEqual = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
s === void 0 && m(), s(e, r) && x({
actual: e,
expected: r,
message: i,
operator: "notDeepEqual",
stackStartFn: a
});
}, y.deepStrictEqual = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
s === void 0 && m(), d(e, r) || x({
actual: e,
expected: r,
message: i,
operator: "deepStrictEqual",
stackStartFn: a
});
}, y.notDeepStrictEqual = oe;
function oe(a, e, r) {
if (arguments.length < 2)
throw new j("actual", "expected");
s === void 0 && m(), d(a, e) && x({
actual: a,
expected: e,
message: r,
operator: "notDeepStrictEqual",
stackStartFn: oe
});
}
y.strictEqual = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
Z(e, r) || x({
actual: e,
expected: r,
message: i,
operator: "strictEqual",
stackStartFn: a
});
}, y.notStrictEqual = function a(e, r, i) {
if (arguments.length < 2)
throw new j("actual", "expected");
Z(e, r) && x({
actual: e,
expected: r,
message: i,
operator: "notStrictEqual",
stackStartFn: a
});
};
var me = /* @__PURE__ */ g(function a(e, r, i) {
var b = this;
_(this, a), r.forEach(function(O) {
O in e && (i !== void 0 && typeof i[O] == "string" && F(e[O]) && u(e[O], i[O]) ? b[O] = i[O] : b[O] = e[O]);
});
});
function de(a, e, r, i, b, O) {
if (!(r in a) || !d(a[r], e[r])) {
if (!i) {
var U = new me(a, b), J = new me(e, b, a), K = new C({
actual: U,
expected: J,
operator: "deepStrictEqual",
stackStartFn: O
});
throw K.actual = a, K.expected = e, K.operator = O.name, K;
}
x({
actual: a,
expected: e,
message: i,
operator: O.name,
stackStartFn: O
});
}
}
function l(a, e, r, i) {
if (typeof e != "function") {
if (F(e))
return u(e, a);
if (arguments.length === 2)
throw new $("expected", ["Function", "RegExp"], e);
if (c(a) !== "object" || a === null) {
var b = new C({
actual: a,
expected: e,
message: r,
operator: "deepStrictEqual",
stackStartFn: i
});
throw b.operator = i.name, b;
}
var O = Object.keys(e);
if (e instanceof Error)
O.push("name", "message");
else if (O.length === 0)
throw new Y("error", e, "may not be an empty object");
return s === void 0 && m(), O.forEach(function(U) {
typeof a[U] == "string" && F(e[U]) && u(e[U], a[U]) || de(a, e, U, r, O, i);
}), !0;
}
return e.prototype !== void 0 && a instanceof e ? !0 : Error.isPrototypeOf(e) ? !1 : e.call({}, a) === !0;
}
function p(a) {
if (typeof a != "function")
throw new $("fn", "Function", a);
try {
a();
} catch (e) {
return e;
}
return X;
}
function w(a) {
return N(a) || a !== null && c(a) === "object" && typeof a.then == "function" && typeof a.catch == "function";
}
function v(a) {
return Promise.resolve().then(function() {
var e;
if (typeof a == "function") {
if (e = a(), !w(e))
throw new A("instance of Promise", "promiseFn", e);
} else if (w(a))
e = a;
else
throw new $("promiseFn", ["Function", "Promise"], a);
return Promise.resolve().then(function() {
return e;
}).then(function() {
return X;
}).catch(function(r) {
return r;
});
});
}
function P(a, e, r, i) {
if (typeof r == "string") {
if (arguments.length === 4)
throw new $("error", ["Object", "Error", "Function", "RegExp"], r);
if (c(e) === "object" && e !== null) {
if (e.message === r)
throw new G("error/message", 'The error message "'.concat(e.message, '" is identical to the message.'));
} else if (e === r)
throw new G("error/message", 'The error "'.concat(e, '" is identical to the message.'));
i = r, r = void 0;
} else if (r != null && c(r) !== "object" && typeof r != "function")
throw new $("error", ["Object", "Error", "Function", "RegExp"], r);
if (e === X) {
var b = "";
r && r.name && (b += " (".concat(r.name, ")")), b += i ? ": ".concat(i) : ".";
var O = a.name === "rejects" ? "rejection" : "exception";
x({
actual: void 0,
expected: r,
operator: a.name,
message: "Missing expected ".concat(O).concat(b),
stackStartFn: a
});
}
if (r && !l(e, r, i, a))
throw e;
}
function k(a, e, r, i) {
if (e !== X) {
if (typeof r == "string" && (i = r, r = void 0), !r || l(e, r)) {
var b = i ? ": ".concat(i) : ".", O = a.name === "doesNotReject" ? "rejection" : "exception";
x({
actual: e,
expected: r,
operator: a.name,
message: "Got unwanted ".concat(O).concat(b, `
`) + 'Actual message: "'.concat(e && e.message, '"'),
stackStartFn: a
});
}
throw e;
}
}
y.throws = function a(e) {
for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), b = 1; b < r; b++)
i[b - 1] = arguments[b];
P.apply(void 0, [a, p(e)].concat(i));
}, y.rejects = function a(e) {
for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), b = 1; b < r; b++)
i[b - 1] = arguments[b];
return v(e).then(function(O) {
return P.apply(void 0, [a, O].concat(i));
});
}, y.doesNotThrow = function a(e) {
for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), b = 1; b < r; b++)
i[b - 1] = arguments[b];
k.apply(void 0, [a, p(e)].concat(i));
}, y.doesNotReject = function a(e) {
for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), b = 1; b < r; b++)
i[b - 1] = arguments[b];
return v(e).then(function(O) {
return k.apply(void 0, [a, O].concat(i));
});
}, y.ifError = function a(e) {
if (e != null) {
var r = "ifError got unwanted exception: ";
c(e) === "object" && typeof e.message == "string" ? e.message.length === 0 && e.constructor ? r += e.constructor.name : r += e.message : r += q(e);
var i = new C({
actual: e,
expected: null,
operator: "ifError",
message: r,
stackStartFn: a
}), b = e.stack;
if (typeof b == "string") {
var O = b.split(`
`);
O.shift();
for (var U = i.stack.split(`
`), J = 0; J < O.length; J++) {
var K = U.indexOf(O[J]);
if (K !== -1) {
U = U.slice(0, K);
break;
}
}
i.stack = "".concat(U.join(`
`), `
`).concat(O.join(`
`));
}
throw i;
}
};
function Q(a, e, r, i, b) {
if (!F(e))
throw new $("regexp", "RegExp", e);
var O = b === "match";
if (typeof a != "string" || u(e, a) !== O) {
if (r instanceof Error)
throw r;
var U = !r;
r = r || (typeof a != "string" ? 'The "string" argument must be of type string. Received type ' + "".concat(c(a), " (").concat(q(a), ")") : (O ? "The input did not match the regular expression " : "The input was expected to not match the regular expression ") + "".concat(q(e), `. Input:
`).concat(q(a), `
`));
var J = new C({
actual: a,
expected: e,
message: r,
operator: b,
stackStartFn: i
});
throw J.generatedMessage = U, J;
}
}
y.match = function a(e, r, i) {
Q(e, r, i, a, "match");
}, y.doesNotMatch = function a(e, r, i) {
Q(e, r, i, a, "doesNotMatch");
};
function z() {
for (var a = arguments.length, e = new Array(a), r = 0; r < a; r++)
e[r] = arguments[r];
pe.apply(void 0, [z, e.length].concat(e));
}
return y.strict = re(z, y, {
equal: y.strictEqual,
deepEqual: y.deepStrictEqual,
notEqual: y.notStrictEqual,
notDeepEqual: y.notDeepStrictEqual
}), y.strict.strict = y.strict, Ie.exports;
}
var xt = Ce();
function Ye(c) {
if (typeof c._id != "string")
throw new Error("Invalid conversation data: _id must be a string");
if (!Array.isArray(c.messages))
throw new Error("Invalid conversation data: messages must be an array");
if (typeof c.createdAt != "number" || new Date(c.createdAt).getTime() !== c.createdAt)
throw new Error(
`Invalid conversation data: createdAt must be a valid datetime number. Got ${c.createdAt}`
);
return {
_id: c._id,
messages: c.messages,
createdAt: c.createdAt
};
}
const _t = "X-Request-Origin";
function Mt() {
if (typeof window < "u")
return window.location.href;
}
class Me extends Error {
constructor(o, g = {}) {
const { retryAfter: f = 1e3, data: S } = g;
super(o), this.name = "RetriableError", this.message = o, this.retryAfter = f, this.data = S;
}
}
class Dt extends Error {
constructor(o) {
super(o), this.name = "TimeoutError", this.message = o;
}
}
function Ct(c) {
const o = c;
return typeof o.type == "string" && typeof o.data < "u";
}
const Ut = (c) => c === "delta" || c === "references" || c === "metadata" || c === "finished", Ft = (c) => {
const o = c;
return o.type === "delta" && typeof o.data == "string" || o.type === "references" && typeof o.data == "object" || o.type === "metadata" && typeof o.data == "object" || o.type === "finished" && typeof o.data == "string";
};
class Lt {
constructor(o) {
xt.strict(
o.serverUrl,
"You must define a serverUrl for the ConversationService"
), this.serverUrl = o.serverUrl.startsWith("/") ? new URL(
o.serverUrl,
window.location.protocol + "//" + window.location.host
).href : o.serverUrl;
const g = new Headers({
"Content-Type": "application/json",