@neuroequality/neuroadapt-ai
Version:
AI-powered accessibility personalization for neurodivergent users
1,594 lines • 98.7 kB
JavaScript
function u(n, e, t, s, r) {
if (typeof e == "function" ? n !== e || !0 : !e.has(n))
throw new TypeError("Cannot write private member to an object whose class did not declare it");
return e.set(n, t), t;
}
function a(n, e, t, s) {
if (t === "a" && !s)
throw new TypeError("Private accessor was defined without a getter");
if (typeof e == "function" ? n !== e || !s : !e.has(n))
throw new TypeError("Cannot read private member from an object whose class did not declare it");
return t === "m" ? s : t === "a" ? s.call(n) : s ? s.value : e.get(n);
}
let Mt = function() {
const { crypto: n } = globalThis;
if (n?.randomUUID)
return Mt = n.randomUUID.bind(n), n.randomUUID();
const e = new Uint8Array(1), t = n ? () => n.getRandomValues(e)[0] : () => Math.random() * 255 & 255;
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (s) => (+s ^ t() & 15 >> +s / 4).toString(16));
};
function te(n) {
return typeof n == "object" && n !== null && // Spec-compliant fetch implementations
("name" in n && n.name === "AbortError" || // Expo fetch
"message" in n && String(n.message).includes("FetchRequestCanceledException"));
}
const We = (n) => {
if (n instanceof Error)
return n;
if (typeof n == "object" && n !== null) {
try {
if (Object.prototype.toString.call(n) === "[object Error]") {
const e = new Error(n.message, n.cause ? { cause: n.cause } : {});
return n.stack && (e.stack = n.stack), n.cause && !e.cause && (e.cause = n.cause), n.name && (e.name = n.name), e;
}
} catch {
}
try {
return new Error(JSON.stringify(n));
} catch {
}
}
return new Error(n);
};
class d extends Error {
}
class y extends d {
constructor(e, t, s, r) {
super(`${y.makeMessage(e, t, s)}`), this.status = e, this.headers = r, this.requestID = r?.get("request-id"), this.error = t;
}
static makeMessage(e, t, s) {
const r = t?.message ? typeof t.message == "string" ? t.message : JSON.stringify(t.message) : t ? JSON.stringify(t) : s;
return e && r ? `${e} ${r}` : e ? `${e} status code (no body)` : r || "(no status code or body)";
}
static generate(e, t, s, r) {
if (!e || !r)
return new Te({ message: s, cause: We(t) });
const i = t;
return e === 400 ? new Rt(e, i, s, r) : e === 401 ? new Pt(e, i, s, r) : e === 403 ? new Et(e, i, s, r) : e === 404 ? new Tt(e, i, s, r) : e === 409 ? new At(e, i, s, r) : e === 422 ? new $t(e, i, s, r) : e === 429 ? new Ot(e, i, s, r) : e >= 500 ? new It(e, i, s, r) : new y(e, i, s, r);
}
}
class P extends y {
constructor({ message: e } = {}) {
super(void 0, void 0, e || "Request was aborted.", void 0);
}
}
class Te extends y {
constructor({ message: e, cause: t }) {
super(void 0, void 0, e || "Connection error.", void 0), t && (this.cause = t);
}
}
class xt extends Te {
constructor({ message: e } = {}) {
super({ message: e ?? "Request timed out." });
}
}
class Rt extends y {
}
class Pt extends y {
}
class Et extends y {
}
class Tt extends y {
}
class At extends y {
}
class $t extends y {
}
class Ot extends y {
}
class It extends y {
}
const Yt = /^[a-z][a-z0-9+.-]*:/i, Zt = (n) => Yt.test(n);
let De = (n) => (De = Array.isArray, De(n)), tt = De;
function st(n) {
return typeof n != "object" ? {} : n ?? {};
}
function es(n) {
if (!n)
return !0;
for (const e in n)
return !1;
return !0;
}
function ts(n, e) {
return Object.prototype.hasOwnProperty.call(n, e);
}
const ss = (n, e) => {
if (typeof e != "number" || !Number.isInteger(e))
throw new d(`${n} must be an integer`);
if (e < 0)
throw new d(`${n} must be a positive integer`);
return e;
}, Nt = (n) => {
try {
return JSON.parse(n);
} catch {
return;
}
}, ns = (n) => new Promise((e) => setTimeout(e, n)), U = "0.56.0", rs = () => (
// @ts-ignore
typeof window < "u" && // @ts-ignore
typeof window.document < "u" && // @ts-ignore
typeof navigator < "u"
);
function is() {
return typeof Deno < "u" && Deno.build != null ? "deno" : typeof EdgeRuntime < "u" ? "edge" : Object.prototype.toString.call(typeof globalThis.process < "u" ? globalThis.process : 0) === "[object process]" ? "node" : "unknown";
}
const as = () => {
const n = is();
if (n === "deno")
return {
"X-Stainless-Lang": "js",
"X-Stainless-Package-Version": U,
"X-Stainless-OS": rt(Deno.build.os),
"X-Stainless-Arch": nt(Deno.build.arch),
"X-Stainless-Runtime": "deno",
"X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
};
if (typeof EdgeRuntime < "u")
return {
"X-Stainless-Lang": "js",
"X-Stainless-Package-Version": U,
"X-Stainless-OS": "Unknown",
"X-Stainless-Arch": `other:${EdgeRuntime}`,
"X-Stainless-Runtime": "edge",
"X-Stainless-Runtime-Version": globalThis.process.version
};
if (n === "node")
return {
"X-Stainless-Lang": "js",
"X-Stainless-Package-Version": U,
"X-Stainless-OS": rt(globalThis.process.platform ?? "unknown"),
"X-Stainless-Arch": nt(globalThis.process.arch ?? "unknown"),
"X-Stainless-Runtime": "node",
"X-Stainless-Runtime-Version": globalThis.process.version ?? "unknown"
};
const e = os();
return e ? {
"X-Stainless-Lang": "js",
"X-Stainless-Package-Version": U,
"X-Stainless-OS": "Unknown",
"X-Stainless-Arch": "unknown",
"X-Stainless-Runtime": `browser:${e.browser}`,
"X-Stainless-Runtime-Version": e.version
} : {
"X-Stainless-Lang": "js",
"X-Stainless-Package-Version": U,
"X-Stainless-OS": "Unknown",
"X-Stainless-Arch": "unknown",
"X-Stainless-Runtime": "unknown",
"X-Stainless-Runtime-Version": "unknown"
};
};
function os() {
if (typeof navigator > "u" || !navigator)
return null;
const n = [
{ key: "edge", pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
{ key: "ie", pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
{ key: "ie", pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
{ key: "chrome", pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
{ key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
{ key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
];
for (const { key: e, pattern: t } of n) {
const s = t.exec(navigator.userAgent);
if (s) {
const r = s[1] || 0, i = s[2] || 0, o = s[3] || 0;
return { browser: e, version: `${r}.${i}.${o}` };
}
}
return null;
}
const nt = (n) => n === "x32" ? "x32" : n === "x86_64" || n === "x64" ? "x64" : n === "arm" ? "arm" : n === "aarch64" || n === "arm64" ? "arm64" : n ? `other:${n}` : "unknown", rt = (n) => (n = n.toLowerCase(), n.includes("ios") ? "iOS" : n === "android" ? "Android" : n === "darwin" ? "MacOS" : n === "win32" ? "Windows" : n === "freebsd" ? "FreeBSD" : n === "openbsd" ? "OpenBSD" : n === "linux" ? "Linux" : n ? `Other:${n}` : "Unknown");
let it;
const cs = () => it ?? (it = as());
function ls() {
if (typeof fetch < "u")
return fetch;
throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
}
function jt(...n) {
const e = globalThis.ReadableStream;
if (typeof e > "u")
throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
return new e(...n);
}
function Lt(n) {
let e = Symbol.asyncIterator in n ? n[Symbol.asyncIterator]() : n[Symbol.iterator]();
return jt({
start() {
},
async pull(t) {
const { done: s, value: r } = await e.next();
s ? t.close() : t.enqueue(r);
},
async cancel() {
await e.return?.();
}
});
}
function Ke(n) {
if (n[Symbol.asyncIterator])
return n;
const e = n.getReader();
return {
async next() {
try {
const t = await e.read();
return t?.done && e.releaseLock(), t;
} catch (t) {
throw e.releaseLock(), t;
}
},
async return() {
const t = e.cancel();
return e.releaseLock(), await t, { done: !0, value: void 0 };
},
[Symbol.asyncIterator]() {
return this;
}
};
}
async function us(n) {
if (n === null || typeof n != "object")
return;
if (n[Symbol.asyncIterator]) {
await n[Symbol.asyncIterator]().return?.();
return;
}
const e = n.getReader(), t = e.cancel();
e.releaseLock(), await t;
}
const hs = ({ headers: n, body: e }) => ({
bodyHeaders: {
"content-type": "application/json"
},
body: JSON.stringify(e)
});
function ds(n) {
let e = 0;
for (const r of n)
e += r.length;
const t = new Uint8Array(e);
let s = 0;
for (const r of n)
t.set(r, s), s += r.length;
return t;
}
let at;
function Ve(n) {
let e;
return (at ?? (e = new globalThis.TextEncoder(), at = e.encode.bind(e)))(n);
}
let ot;
function ct(n) {
let e;
return (ot ?? (e = new globalThis.TextDecoder(), ot = e.decode.bind(e)))(n);
}
var w, S;
class se {
constructor() {
w.set(this, void 0), S.set(this, void 0), u(this, w, new Uint8Array()), u(this, S, null);
}
decode(e) {
if (e == null)
return [];
const t = e instanceof ArrayBuffer ? new Uint8Array(e) : typeof e == "string" ? Ve(e) : e;
u(this, w, ds([a(this, w, "f"), t]));
const s = [];
let r;
for (; (r = fs(a(this, w, "f"), a(this, S, "f"))) != null; ) {
if (r.carriage && a(this, S, "f") == null) {
u(this, S, r.index);
continue;
}
if (a(this, S, "f") != null && (r.index !== a(this, S, "f") + 1 || r.carriage)) {
s.push(ct(a(this, w, "f").subarray(0, a(this, S, "f") - 1))), u(this, w, a(this, w, "f").subarray(a(this, S, "f"))), u(this, S, null);
continue;
}
const i = a(this, S, "f") !== null ? r.preceding - 1 : r.preceding, o = ct(a(this, w, "f").subarray(0, i));
s.push(o), u(this, w, a(this, w, "f").subarray(r.index)), u(this, S, null);
}
return s;
}
flush() {
return a(this, w, "f").length ? this.decode(`
`) : [];
}
}
w = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap();
se.NEWLINE_CHARS = /* @__PURE__ */ new Set([`
`, "\r"]);
se.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
function fs(n, e) {
for (let r = e ?? 0; r < n.length; r++) {
if (n[r] === 10)
return { preceding: r, index: r + 1, carriage: !1 };
if (n[r] === 13)
return { preceding: r, index: r + 1, carriage: !0 };
}
return null;
}
function ps(n) {
for (let s = 0; s < n.length - 1; s++) {
if (n[s] === 10 && n[s + 1] === 10 || n[s] === 13 && n[s + 1] === 13)
return s + 2;
if (n[s] === 13 && n[s + 1] === 10 && s + 3 < n.length && n[s + 2] === 13 && n[s + 3] === 10)
return s + 4;
}
return -1;
}
const Re = {
off: 0,
error: 200,
warn: 300,
info: 400,
debug: 500
}, lt = (n, e, t) => {
if (n) {
if (ts(Re, n))
return n;
b(t).warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(Re))}`);
}
};
function Z() {
}
function oe(n, e, t) {
return !e || Re[n] > Re[t] ? Z : e[n].bind(e);
}
const gs = {
error: Z,
warn: Z,
info: Z,
debug: Z
};
let ut = /* @__PURE__ */ new WeakMap();
function b(n) {
const e = n.logger, t = n.logLevel ?? "off";
if (!e)
return gs;
const s = ut.get(e);
if (s && s[0] === t)
return s[1];
const r = {
error: oe("error", e, t),
warn: oe("warn", e, t),
info: oe("info", e, t),
debug: oe("debug", e, t)
};
return ut.set(e, [t, r]), r;
}
const B = (n) => (n.options && (n.options = { ...n.options }, delete n.options.headers), n.headers && (n.headers = Object.fromEntries((n.headers instanceof Headers ? [...n.headers] : Object.entries(n.headers)).map(([e, t]) => [
e,
e.toLowerCase() === "x-api-key" || e.toLowerCase() === "authorization" || e.toLowerCase() === "cookie" || e.toLowerCase() === "set-cookie" ? "***" : t
]))), "retryOfRequestLogID" in n && (n.retryOfRequestLogID && (n.retryOf = n.retryOfRequestLogID), delete n.retryOfRequestLogID), n);
var W;
class A {
constructor(e, t, s) {
this.iterator = e, W.set(this, void 0), this.controller = t, u(this, W, s);
}
static fromSSEResponse(e, t, s) {
let r = !1;
const i = s ? b(s) : console;
async function* o() {
if (r)
throw new d("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
r = !0;
let c = !1;
try {
for await (const l of ms(e, t)) {
if (l.event === "completion")
try {
yield JSON.parse(l.data);
} catch (f) {
throw i.error("Could not parse message into JSON:", l.data), i.error("From chunk:", l.raw), f;
}
if (l.event === "message_start" || l.event === "message_delta" || l.event === "message_stop" || l.event === "content_block_start" || l.event === "content_block_delta" || l.event === "content_block_stop")
try {
yield JSON.parse(l.data);
} catch (f) {
throw i.error("Could not parse message into JSON:", l.data), i.error("From chunk:", l.raw), f;
}
if (l.event !== "ping" && l.event === "error")
throw new y(void 0, Nt(l.data) ?? l.data, void 0, e.headers);
}
c = !0;
} catch (l) {
if (te(l))
return;
throw l;
} finally {
c || t.abort();
}
}
return new A(o, t, s);
}
/**
* Generates a Stream from a newline-separated ReadableStream
* where each item is a JSON value.
*/
static fromReadableStream(e, t, s) {
let r = !1;
async function* i() {
const c = new se(), l = Ke(e);
for await (const f of l)
for (const m of c.decode(f))
yield m;
for (const f of c.flush())
yield f;
}
async function* o() {
if (r)
throw new d("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
r = !0;
let c = !1;
try {
for await (const l of i())
c || l && (yield JSON.parse(l));
c = !0;
} catch (l) {
if (te(l))
return;
throw l;
} finally {
c || t.abort();
}
}
return new A(o, t, s);
}
[(W = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
return this.iterator();
}
/**
* Splits the stream into two streams which can be
* independently read from at different speeds.
*/
tee() {
const e = [], t = [], s = this.iterator(), r = (i) => ({
next: () => {
if (i.length === 0) {
const o = s.next();
e.push(o), t.push(o);
}
return i.shift();
}
});
return [
new A(() => r(e), this.controller, a(this, W, "f")),
new A(() => r(t), this.controller, a(this, W, "f"))
];
}
/**
* Converts this stream to a newline-separated ReadableStream of
* JSON stringified values in the stream
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
*/
toReadableStream() {
const e = this;
let t;
return jt({
async start() {
t = e[Symbol.asyncIterator]();
},
async pull(s) {
try {
const { value: r, done: i } = await t.next();
if (i)
return s.close();
const o = Ve(JSON.stringify(r) + `
`);
s.enqueue(o);
} catch (r) {
s.error(r);
}
},
async cancel() {
await t.return?.();
}
});
}
}
async function* ms(n, e) {
if (!n.body)
throw e.abort(), typeof globalThis.navigator < "u" && globalThis.navigator.product === "ReactNative" ? new d("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new d("Attempted to iterate over a response with no body");
const t = new ys(), s = new se(), r = Ke(n.body);
for await (const i of _s(r))
for (const o of s.decode(i)) {
const c = t.decode(o);
c && (yield c);
}
for (const i of s.flush()) {
const o = t.decode(i);
o && (yield o);
}
}
async function* _s(n) {
let e = new Uint8Array();
for await (const t of n) {
if (t == null)
continue;
const s = t instanceof ArrayBuffer ? new Uint8Array(t) : typeof t == "string" ? Ve(t) : t;
let r = new Uint8Array(e.length + s.length);
r.set(e), r.set(s, e.length), e = r;
let i;
for (; (i = ps(e)) !== -1; )
yield e.slice(0, i), e = e.slice(i);
}
e.length > 0 && (yield e);
}
class ys {
constructor() {
this.event = null, this.data = [], this.chunks = [];
}
decode(e) {
if (e.endsWith("\r") && (e = e.substring(0, e.length - 1)), !e) {
if (!this.event && !this.data.length)
return null;
const i = {
event: this.event,
data: this.data.join(`
`),
raw: this.chunks
};
return this.event = null, this.data = [], this.chunks = [], i;
}
if (this.chunks.push(e), e.startsWith(":"))
return null;
let [t, s, r] = bs(e, ":");
return r.startsWith(" ") && (r = r.substring(1)), t === "event" ? this.event = r : t === "data" && this.data.push(r), null;
}
}
function bs(n, e) {
const t = n.indexOf(e);
return t !== -1 ? [n.substring(0, t), e, n.substring(t + e.length)] : [n, "", ""];
}
async function Bt(n, e) {
const { response: t, requestLogID: s, retryOfRequestLogID: r, startTime: i } = e, o = await (async () => {
if (e.options.stream)
return b(n).debug("response", t.status, t.url, t.headers, t.body), e.options.__streamClass ? e.options.__streamClass.fromSSEResponse(t, e.controller, n) : A.fromSSEResponse(t, e.controller, n);
if (t.status === 204)
return null;
if (e.options.__binaryResponse)
return t;
const l = t.headers.get("content-type")?.split(";")[0]?.trim();
if (l?.includes("application/json") || l?.endsWith("+json")) {
const _ = await t.json();
return qt(_, t);
}
return await t.text();
})();
return b(n).debug(`[${s}] response parsed`, B({
retryOfRequestLogID: r,
url: t.url,
status: t.status,
body: o,
durationMs: Date.now() - i
})), o;
}
function qt(n, e) {
return !n || typeof n != "object" || Array.isArray(n) ? n : Object.defineProperty(n, "_request_id", {
value: e.headers.get("request-id"),
enumerable: !1
});
}
var ee;
class Ae extends Promise {
constructor(e, t, s = Bt) {
super((r) => {
r(null);
}), this.responsePromise = t, this.parseResponse = s, ee.set(this, void 0), u(this, ee, e);
}
_thenUnwrap(e) {
return new Ae(a(this, ee, "f"), this.responsePromise, async (t, s) => qt(e(await this.parseResponse(t, s), s), s.response));
}
/**
* Gets the raw `Response` instance instead of parsing the response
* data.
*
* If you want to parse the response body but still get the `Response`
* instance, you can use {@link withResponse()}.
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
* to your `tsconfig.json`.
*/
asResponse() {
return this.responsePromise.then((e) => e.response);
}
/**
* Gets the parsed response data, the raw `Response` instance and the ID of the request,
* returned via the `request-id` header which is useful for debugging requests and resporting
* issues to Anthropic.
*
* If you just want to get the raw `Response` instance without parsing it,
* you can use {@link asResponse()}.
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
* to your `tsconfig.json`.
*/
async withResponse() {
const [e, t] = await Promise.all([this.parse(), this.asResponse()]);
return { data: e, response: t, request_id: t.headers.get("request-id") };
}
parse() {
return this.parsedPromise || (this.parsedPromise = this.responsePromise.then((e) => this.parseResponse(a(this, ee, "f"), e))), this.parsedPromise;
}
then(e, t) {
return this.parse().then(e, t);
}
catch(e) {
return this.parse().catch(e);
}
finally(e) {
return this.parse().finally(e);
}
}
ee = /* @__PURE__ */ new WeakMap();
var ce;
class ws {
constructor(e, t, s, r) {
ce.set(this, void 0), u(this, ce, e), this.options = r, this.response = t, this.body = s;
}
hasNextPage() {
return this.getPaginatedItems().length ? this.nextPageRequestOptions() != null : !1;
}
async getNextPage() {
const e = this.nextPageRequestOptions();
if (!e)
throw new d("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
return await a(this, ce, "f").requestAPIList(this.constructor, e);
}
async *iterPages() {
let e = this;
for (yield e; e.hasNextPage(); )
e = await e.getNextPage(), yield e;
}
async *[(ce = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
for await (const e of this.iterPages())
for (const t of e.getPaginatedItems())
yield t;
}
}
class Ss extends Ae {
constructor(e, t, s) {
super(e, t, async (r, i) => new s(r, i.response, await Bt(r, i), i.options));
}
/**
* Allow auto-paginating iteration on an unawaited list call, eg:
*
* for await (const item of client.items.list()) {
* console.log(item)
* }
*/
async *[Symbol.asyncIterator]() {
const e = await this;
for await (const t of e)
yield t;
}
}
class ne extends ws {
constructor(e, t, s, r) {
super(e, t, s, r), this.data = s.data || [], this.has_more = s.has_more || !1, this.first_id = s.first_id || null, this.last_id = s.last_id || null;
}
getPaginatedItems() {
return this.data ?? [];
}
hasNextPage() {
return this.has_more === !1 ? !1 : super.hasNextPage();
}
nextPageRequestOptions() {
if (this.options.query?.before_id) {
const t = this.first_id;
return t ? {
...this.options,
query: {
...st(this.options.query),
before_id: t
}
} : null;
}
const e = this.last_id;
return e ? {
...this.options,
query: {
...st(this.options.query),
after_id: e
}
} : null;
}
}
const vt = () => {
if (typeof File > "u") {
const { process: n } = globalThis, e = typeof n?.versions?.node == "string" && parseInt(n.versions.node.split(".")) < 20;
throw new Error("`File` is not defined as a global, which is required for file uploads." + (e ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
}
};
function F(n, e, t) {
return vt(), new File(n, e ?? "unknown_file", t);
}
function Me(n) {
return (typeof n == "object" && n !== null && ("name" in n && n.name && String(n.name) || "url" in n && n.url && String(n.url) || "filename" in n && n.filename && String(n.filename) || "path" in n && n.path && String(n.path)) || "").split(/[\\/]/).pop() || void 0;
}
const Ut = (n) => n != null && typeof n == "object" && typeof n[Symbol.asyncIterator] == "function", ks = async (n, e) => ({ ...n, body: await xs(n.body, e) }), ht = /* @__PURE__ */ new WeakMap();
function Ms(n) {
const e = typeof n == "function" ? n : n.fetch, t = ht.get(e);
if (t)
return t;
const s = (async () => {
try {
const r = "Response" in e ? e.Response : (await e("data:,")).constructor, i = new FormData();
return i.toString() !== await new r(i).text();
} catch {
return !0;
}
})();
return ht.set(e, s), s;
}
const xs = async (n, e) => {
if (!await Ms(e))
throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
const t = new FormData();
return await Promise.all(Object.entries(n || {}).map(([s, r]) => He(t, s, r))), t;
}, Rs = (n) => n instanceof Blob && "name" in n, He = async (n, e, t) => {
if (t !== void 0) {
if (t == null)
throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);
if (typeof t == "string" || typeof t == "number" || typeof t == "boolean")
n.append(e, String(t));
else if (t instanceof Response) {
let s = {};
const r = t.headers.get("Content-Type");
r && (s = { type: r }), n.append(e, F([await t.blob()], Me(t), s));
} else if (Ut(t))
n.append(e, F([await new Response(Lt(t)).blob()], Me(t)));
else if (Rs(t))
n.append(e, F([t], Me(t), { type: t.type }));
else if (Array.isArray(t))
await Promise.all(t.map((s) => He(n, e + "[]", s)));
else if (typeof t == "object")
await Promise.all(Object.entries(t).map(([s, r]) => He(n, `${e}[${s}]`, r)));
else
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`);
}
}, Ct = (n) => n != null && typeof n == "object" && typeof n.size == "number" && typeof n.type == "string" && typeof n.text == "function" && typeof n.slice == "function" && typeof n.arrayBuffer == "function", Ps = (n) => n != null && typeof n == "object" && typeof n.name == "string" && typeof n.lastModified == "number" && Ct(n), Es = (n) => n != null && typeof n == "object" && typeof n.url == "string" && typeof n.blob == "function";
async function Ts(n, e, t) {
if (vt(), n = await n, e || (e = Me(n)), Ps(n))
return n instanceof File && e == null && t == null ? n : F([await n.arrayBuffer()], e ?? n.name, {
type: n.type,
lastModified: n.lastModified,
...t
});
if (Es(n)) {
const r = await n.blob();
return e || (e = new URL(n.url).pathname.split(/[\\/]/).pop()), F(await Xe(r), e, t);
}
const s = await Xe(n);
if (!t?.type) {
const r = s.find((i) => typeof i == "object" && "type" in i && i.type);
typeof r == "string" && (t = { ...t, type: r });
}
return F(s, e, t);
}
async function Xe(n) {
let e = [];
if (typeof n == "string" || ArrayBuffer.isView(n) || // includes Uint8Array, Buffer, etc.
n instanceof ArrayBuffer)
e.push(n);
else if (Ct(n))
e.push(n instanceof Blob ? n : await n.arrayBuffer());
else if (Ut(n))
for await (const t of n)
e.push(...await Xe(t));
else {
const t = n?.constructor?.name;
throw new Error(`Unexpected data type: ${typeof n}${t ? `; constructor: ${t}` : ""}${As(n)}`);
}
return e;
}
function As(n) {
return typeof n != "object" || n === null ? "" : `; props: [${Object.getOwnPropertyNames(n).map((t) => `"${t}"`).join(", ")}]`;
}
class N {
constructor(e) {
this._client = e;
}
}
const Ft = Symbol.for("brand.privateNullableHeaders");
function* $s(n) {
if (!n)
return;
if (Ft in n) {
const { values: s, nulls: r } = n;
yield* s.entries();
for (const i of r)
yield [i, null];
return;
}
let e = !1, t;
n instanceof Headers ? t = n.entries() : tt(n) ? t = n : (e = !0, t = Object.entries(n ?? {}));
for (let s of t) {
const r = s[0];
if (typeof r != "string")
throw new TypeError("expected header name to be a string");
const i = tt(s[1]) ? s[1] : [s[1]];
let o = !1;
for (const c of i)
c !== void 0 && (e && !o && (o = !0, yield [r, null]), yield [r, c]);
}
}
const p = (n) => {
const e = new Headers(), t = /* @__PURE__ */ new Set();
for (const s of n) {
const r = /* @__PURE__ */ new Set();
for (const [i, o] of $s(s)) {
const c = i.toLowerCase();
r.has(c) || (e.delete(i), r.add(c)), o === null ? (e.delete(i), t.add(c)) : (e.append(i, o), t.delete(c));
}
}
return { [Ft]: !0, values: e, nulls: t };
};
function Wt(n) {
return n.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
}
const dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), Os = (n = Wt) => function(t, ...s) {
if (t.length === 1)
return t[0];
let r = !1;
const i = [], o = t.reduce((m, _, x) => {
/[?#]/.test(_) && (r = !0);
const h = s[x];
let R = (r ? encodeURIComponent : n)("" + h);
return x !== s.length && (h == null || typeof h == "object" && // handle values from other realms
h.toString === Object.getPrototypeOf(Object.getPrototypeOf(h.hasOwnProperty ?? dt) ?? dt)?.toString) && (R = h + "", i.push({
start: m.length + _.length,
length: R.length,
error: `Value of type ${Object.prototype.toString.call(h).slice(8, -1)} is not a valid path parameter`
})), m + _ + (x === s.length ? "" : R);
}, ""), c = o.split(/[?#]/, 1)[0], l = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
let f;
for (; (f = l.exec(c)) !== null; )
i.push({
start: f.index,
length: f[0].length,
error: `Value "${f[0]}" can't be safely passed as a path parameter`
});
if (i.sort((m, _) => m.start - _.start), i.length > 0) {
let m = 0;
const _ = i.reduce((x, h) => {
const R = " ".repeat(h.start - m), Oe = "^".repeat(h.length);
return m = h.start + h.length, x + R + Oe;
}, "");
throw new d(`Path parameters result in path with invalid segments:
${i.map((x) => x.error).join(`
`)}
${o}
${_}`);
}
return o;
}, E = /* @__PURE__ */ Os(Wt);
class Dt extends N {
/**
* List Files
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const fileMetadata of client.beta.files.list()) {
* // ...
* }
* ```
*/
list(e = {}, t) {
const { betas: s, ...r } = e ?? {};
return this._client.getAPIList("/v1/files", ne, {
query: r,
...t,
headers: p([
{ "anthropic-beta": [...s ?? [], "files-api-2025-04-14"].toString() },
t?.headers
])
});
}
/**
* Delete File
*
* @example
* ```ts
* const deletedFile = await client.beta.files.delete(
* 'file_id',
* );
* ```
*/
delete(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.delete(E`/v1/files/${e}`, {
...s,
headers: p([
{ "anthropic-beta": [...r ?? [], "files-api-2025-04-14"].toString() },
s?.headers
])
});
}
/**
* Download File
*
* @example
* ```ts
* const response = await client.beta.files.download(
* 'file_id',
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
download(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.get(E`/v1/files/${e}/content`, {
...s,
headers: p([
{
"anthropic-beta": [...r ?? [], "files-api-2025-04-14"].toString(),
Accept: "application/binary"
},
s?.headers
]),
__binaryResponse: !0
});
}
/**
* Get File Metadata
*
* @example
* ```ts
* const fileMetadata =
* await client.beta.files.retrieveMetadata('file_id');
* ```
*/
retrieveMetadata(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.get(E`/v1/files/${e}`, {
...s,
headers: p([
{ "anthropic-beta": [...r ?? [], "files-api-2025-04-14"].toString() },
s?.headers
])
});
}
/**
* Upload File
*
* @example
* ```ts
* const fileMetadata = await client.beta.files.upload({
* file: fs.createReadStream('path/to/file'),
* });
* ```
*/
upload(e, t) {
const { betas: s, ...r } = e;
return this._client.post("/v1/files", ks({
body: r,
...t,
headers: p([
{ "anthropic-beta": [...s ?? [], "files-api-2025-04-14"].toString() },
t?.headers
])
}, this._client));
}
}
let Ht = class extends N {
/**
* Get a specific model.
*
* The Models API response can be used to determine information about a specific
* model or resolve a model alias to a model ID.
*
* @example
* ```ts
* const betaModelInfo = await client.beta.models.retrieve(
* 'model_id',
* );
* ```
*/
retrieve(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.get(E`/v1/models/${e}?beta=true`, {
...s,
headers: p([
{ ...r?.toString() != null ? { "anthropic-beta": r?.toString() } : void 0 },
s?.headers
])
});
}
/**
* List available models.
*
* The Models API response can be used to determine which models are available for
* use in the API. More recently released models are listed first.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const betaModelInfo of client.beta.models.list()) {
* // ...
* }
* ```
*/
list(e = {}, t) {
const { betas: s, ...r } = e ?? {};
return this._client.getAPIList("/v1/models?beta=true", ne, {
query: r,
...t,
headers: p([
{ ...s?.toString() != null ? { "anthropic-beta": s?.toString() } : void 0 },
t?.headers
])
});
}
};
class $e {
constructor(e, t) {
this.iterator = e, this.controller = t;
}
async *decoder() {
const e = new se();
for await (const t of this.iterator)
for (const s of e.decode(t))
yield JSON.parse(s);
for (const t of e.flush())
yield JSON.parse(t);
}
[Symbol.asyncIterator]() {
return this.decoder();
}
static fromResponse(e, t) {
if (!e.body)
throw t.abort(), typeof globalThis.navigator < "u" && globalThis.navigator.product === "ReactNative" ? new d("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new d("Attempted to iterate over a response with no body");
return new $e(Ke(e.body), t);
}
}
let Xt = class extends N {
/**
* Send a batch of Message creation requests.
*
* The Message Batches API can be used to process multiple Messages API requests at
* once. Once a Message Batch is created, it begins processing immediately. Batches
* can take up to 24 hours to complete.
*
* Learn more about the Message Batches API in our
* [user guide](/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatch =
* await client.beta.messages.batches.create({
* requests: [
* {
* custom_id: 'my-custom-id-1',
* params: {
* max_tokens: 1024,
* messages: [
* { content: 'Hello, world', role: 'user' },
* ],
* model: 'claude-sonnet-4-20250514',
* },
* },
* ],
* });
* ```
*/
create(e, t) {
const { betas: s, ...r } = e;
return this._client.post("/v1/messages/batches?beta=true", {
body: r,
...t,
headers: p([
{ "anthropic-beta": [...s ?? [], "message-batches-2024-09-24"].toString() },
t?.headers
])
});
}
/**
* This endpoint is idempotent and can be used to poll for Message Batch
* completion. To access the results of a Message Batch, make a request to the
* `results_url` field in the response.
*
* Learn more about the Message Batches API in our
* [user guide](/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatch =
* await client.beta.messages.batches.retrieve(
* 'message_batch_id',
* );
* ```
*/
retrieve(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.get(E`/v1/messages/batches/${e}?beta=true`, {
...s,
headers: p([
{ "anthropic-beta": [...r ?? [], "message-batches-2024-09-24"].toString() },
s?.headers
])
});
}
/**
* List all Message Batches within a Workspace. Most recently created batches are
* returned first.
*
* Learn more about the Message Batches API in our
* [user guide](/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const betaMessageBatch of client.beta.messages.batches.list()) {
* // ...
* }
* ```
*/
list(e = {}, t) {
const { betas: s, ...r } = e ?? {};
return this._client.getAPIList("/v1/messages/batches?beta=true", ne, {
query: r,
...t,
headers: p([
{ "anthropic-beta": [...s ?? [], "message-batches-2024-09-24"].toString() },
t?.headers
])
});
}
/**
* Delete a Message Batch.
*
* Message Batches can only be deleted once they've finished processing. If you'd
* like to delete an in-progress batch, you must first cancel it.
*
* Learn more about the Message Batches API in our
* [user guide](/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaDeletedMessageBatch =
* await client.beta.messages.batches.delete(
* 'message_batch_id',
* );
* ```
*/
delete(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.delete(E`/v1/messages/batches/${e}?beta=true`, {
...s,
headers: p([
{ "anthropic-beta": [...r ?? [], "message-batches-2024-09-24"].toString() },
s?.headers
])
});
}
/**
* Batches may be canceled any time before processing ends. Once cancellation is
* initiated, the batch enters a `canceling` state, at which time the system may
* complete any in-progress, non-interruptible requests before finalizing
* cancellation.
*
* The number of canceled requests is specified in `request_counts`. To determine
* which requests were canceled, check the individual results within the batch.
* Note that cancellation may not result in any canceled requests if they were
* non-interruptible.
*
* Learn more about the Message Batches API in our
* [user guide](/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatch =
* await client.beta.messages.batches.cancel(
* 'message_batch_id',
* );
* ```
*/
cancel(e, t = {}, s) {
const { betas: r } = t ?? {};
return this._client.post(E`/v1/messages/batches/${e}/cancel?beta=true`, {
...s,
headers: p([
{ "anthropic-beta": [...r ?? [], "message-batches-2024-09-24"].toString() },
s?.headers
])
});
}
/**
* Streams the results of a Message Batch as a `.jsonl` file.
*
* Each line in the file is a JSON object containing the result of a single request
* in the Message Batch. Results are not guaranteed to be in the same order as
* requests. Use the `custom_id` field to match results to requests.
*
* Learn more about the Message Batches API in our
* [user guide](/en/docs/build-with-claude/batch-processing)
*
* @example
* ```ts
* const betaMessageBatchIndividualResponse =
* await client.beta.messages.batches.results(
* 'message_batch_id',
* );
* ```
*/
async results(e, t = {}, s) {
const r = await this.retrieve(e);
if (!r.results_url)
throw new d(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);
const { betas: i } = t ?? {};
return this._client.get(r.results_url, {
...s,
headers: p([
{
"anthropic-beta": [...i ?? [], "message-batches-2024-09-24"].toString(),
Accept: "application/binary"
},
s?.headers
]),
stream: !0,
__binaryResponse: !0
})._thenUnwrap((o, c) => $e.fromResponse(c.response, c.controller));
}
};
const Is = (n) => {
let e = 0, t = [];
for (; e < n.length; ) {
let s = n[e];
if (s === "\\") {
e++;
continue;
}
if (s === "{") {
t.push({
type: "brace",
value: "{"
}), e++;
continue;
}
if (s === "}") {
t.push({
type: "brace",
value: "}"
}), e++;
continue;
}
if (s === "[") {
t.push({
type: "paren",
value: "["
}), e++;
continue;
}
if (s === "]") {
t.push({
type: "paren",
value: "]"
}), e++;
continue;
}
if (s === ":") {
t.push({
type: "separator",
value: ":"
}), e++;
continue;
}
if (s === ",") {
t.push({
type: "delimiter",
value: ","
}), e++;
continue;
}
if (s === '"') {
let c = "", l = !1;
for (s = n[++e]; s !== '"'; ) {
if (e === n.length) {
l = !0;
break;
}
if (s === "\\") {
if (e++, e === n.length) {
l = !0;
break;
}
c += s + n[e], s = n[++e];
} else
c += s, s = n[++e];
}
s = n[++e], l || t.push({
type: "string",
value: c
});
continue;
}
if (s && /\s/.test(s)) {
e++;
continue;
}
let i = /[0-9]/;
if (s && i.test(s) || s === "-" || s === ".") {
let c = "";
for (s === "-" && (c += s, s = n[++e]); s && i.test(s) || s === "."; )
c += s, s = n[++e];
t.push({
type: "number",
value: c
});
continue;
}
let o = /[a-z]/i;
if (s && o.test(s)) {
let c = "";
for (; s && o.test(s) && e !== n.length; )
c += s, s = n[++e];
if (c == "true" || c == "false" || c === "null")
t.push({
type: "name",
value: c
});
else {
e++;
continue;
}
continue;
}
e++;
}
return t;
}, C = (n) => {
if (n.length === 0)
return n;
let e = n[n.length - 1];
switch (e.type) {
case "separator":
return n = n.slice(0, n.length - 1), C(n);
case "number":
let t = e.value[e.value.length - 1];
if (t === "." || t === "-")
return n = n.slice(0, n.length - 1), C(n);
case "string":
let s = n[n.length - 2];
if (s?.type === "delimiter")
return n = n.slice(0, n.length - 1), C(n);
if (s?.type === "brace" && s.value === "{")
return n = n.slice(0, n.length - 1), C(n);
break;
case "delimiter":
return n = n.slice(0, n.length - 1), C(n);
}
return n;
}, Ns = (n) => {
let e = [];
return n.map((t) => {
t.type === "brace" && (t.value === "{" ? e.push("}") : e.splice(e.lastIndexOf("}"), 1)), t.type === "paren" && (t.value === "[" ? e.push("]") : e.splice(e.lastIndexOf("]"), 1));
}), e.length > 0 && e.reverse().map((t) => {
t === "}" ? n.push({
type: "brace",
value: "}"
}) : t === "]" && n.push({
type: "paren",
value: "]"
});
}), n;
}, js = (n) => {
let e = "";
return n.map((t) => {
switch (t.type) {
case "string":
e += '"' + t.value + '"';
break;
default:
e += t.value;
break;
}
}), e;
}, Jt = (n) => JSON.parse(js(Ns(C(Is(n)))));
var k, j, D, le, H, X, ue, J, O, K, he, de, q, fe, pe, Ne, ft, ge, je, Le, Be, pt;
const gt = "__json_buf";
function mt(n) {
return n.type === "tool_use" || n.type === "server_tool_use" || n.type === "mcp_tool_use";
}
class Pe {
constructor() {
k.add(this), this.messages = [], this.receivedMessages = [], j.set(this, void 0), this.controller = new AbortController(), D.set(this, void 0), le.set(this, () => {
}), H.set(this, () => {
}), X.set(this, void 0), ue.set(this, () => {
}), J.set(this, () => {
}), O.set(this, {}), K.set(this, !1), he.set(this, !1), de.set(this, !1), q.set(this, !1), fe.set(this, void 0), pe.set(this, void 0), ge.set(this, (e) => {
if (u(this, he, !0), te(e) && (e = new P()), e instanceof P)
return u(this, de, !0), this._emit("abort", e);
if (e instanceof d)
return this._emit("error", e);
if (e instanceof Error) {
const t = new d(e.message);
return t.cause = e, this._emit("error", t);
}
return this._emit("error", new d(String(e)));
}), u(this, D, new Promise((e, t) => {
u(this, le, e, "f"), u(this, H, t, "f");
})), u(this, X, new Promise((e, t) => {
u(this, ue, e, "f"), u(this, J, t, "f");
})), a(this, D, "f").catch(() => {
}), a(this, X, "f").catch(() => {
});
}
get response() {
return a(this, fe, "f");
}
get request_id() {
return a(this, pe, "f");
}
/**
* Returns the `MessageStream` data, the raw `Response` instance and the ID of the request,
* returned vie the `request-id` header which is useful for debugging requests and resporting
* issues to Anthropic.
*
* This is the same as the `APIPromise.withResponse()` method.
*
* This method will raise an error if you created the stream using `MessageStream.fromReadableStream`
* as no `Response` is available.
*/
async withResponse() {
const e = await a(this, D, "f");
if (!e)
throw new Error("Could not resolve a `Response` object");
return {
data: this,
response: e,
request_id: e.headers.get("request-id")
};
}
/**
* Intended for use on the frontend, consuming a stream produced with
* `.toReadableStream()` on the backend.
*
* Note that messages sent to the model do not appear in `.on('message')`
* in this context.
*/
static fromReadableStream(e) {
const t = new Pe();
return t._run(() => t._fromReadableStream(e)), t;
}
static createMessage(e, t, s) {
const r = new Pe();
for (const i of t.messages)
r._addMessageParam(i);
return r._run(() => r._createMessage(e, { ...t, stream: !0 }, { ...s, headers: { ...s?.headers, "X-Stainless-Helper-Method": "stream" } })), r;
}
_run(e) {
e().then(() => {
this._emitFinal(), this._emit("end");
}, a(this, ge, "f"));
}
_addMessageParam(e) {
this.messages.push(e);
}
_addMessage(e, t = !0) {
this.receivedMessages.push(e), t && this._emit("message", e);
}
async _createMessage(e, t, s) {
const r = s?.signal;
let i;
r && (r.aborted && this.controller.abort(), i = this.controller.abort.bind(this.controller), r.addEventListener("abort", i));
try {
a(this, k, "m", je).call(this);
const { response: o, data: c } = await e.create({ ...t, stream: !0 }, { ...s, signal: this.controller.signal }).withResponse();
this._connected(o);
for await (const l of c)
a(this, k, "m", Le).call(this, l);
if (c.controller.signal?.aborted)
throw new P();
a(this, k, "m", Be).call(this);
} finally {
r && i && r.removeEventListener("abort", i);
}
}
_connected(e) {
this.ended || (u(this, fe, e), u(this, pe, e?.headers.get("request-id")), a(this, le, "f").call(this, e), this._emit("connect"));
}
get ended() {
return a(this, K, "f");
}
get errored() {
return a(this, he, "f");
}
get aborted() {
return a(this, de, "f");
}
abort() {
this.controller.abort();
}
/**
* Adds the listener function to the end of the listeners array for the event.
* No checks are made to see if the listener has already been added. Multiple calls passing
* the same combination of event and listener will result in the listener being added, and
* called, multiple times.
* @returns this MessageStream, so that calls can be chained
*/
on(e, t) {
return (a(this, O, "f")[e] || (a(this, O, "f")[e] = [])).push({ listener: t }), this;
}
/**
* Removes the specified listener from the listener array for the event.
* off() will remove, at most, one instance of a listener from the listener array. If any single
* listener has been added multiple times to the listener array for the specified event, then
* off() must be called multiple times to remove each instance.
* @returns this MessageStream, so that calls can be chained
*/
off(e, t) {
const s = a(this, O, "f")[e];
if (!s)
return this;
const r = s.findIndex((i) => i.listener === t);
return r >= 0 && s.splice(r, 1), this;
}
/**
* Adds a one-time listener function for the event. The next time the event is triggered,
* this listener is removed and then invoked.
* @returns this MessageStream, so that calls can be chained
*/
once(e, t) {
return (a(this, O, "f")[e] || (a(this, O, "f")[e] = [])).push({ listener: t, once: !0 }), this;
}
/**
* This is similar to `.once()`, but returns a Promise that resolves the next time
* the event is triggered, instead of calling a listener callback.
* @returns a Promise that resolves the next time given event is triggered,
* or rejects if an error is emitted. (If you request the 'error' event,
* returns a promise that resolves with the error).
*
* Example:
*
* const message = await stream.emitted('message') // rejects if the stream errors
*/
emitted(e) {
return new Promise((t, s) => {
u(this, q, !0), e !== "error" && this.once("error", s), this.once(e, t);
});
}
async done() {
u(this, q, !0), await a(this, X, "f");
}
get currentMessage() {
return a(this, j, "f");
}
/**
* @returns a promise that resolves with the the final assistant Message response,
* or rejects if an error occurred or the stream ended prematurely without producing a Message.
*/
async finalMessage() {
return await this.done(), a(this, k, "m", Ne).call(this);
}
/**
* @returns a promise that resolves with the the final assistant Message's text response, concatenated
* together if there are more than one text blocks.
* Rejects if an error occurred or the stream ended prematurely without producing a Message.
*/
async finalText() {
return await this.done(), a(this, k, "m", ft).call(this);
}
_emit(e, ...t) {
if (a(this, K, "f"))
return;
e === "end" && (u(this, K, !0), a(this, ue, "f").call(this));
const