UNPKG

vue-docs-ui

Version:

A modern documentation UI component library built with Vue 3. Create beautiful documentation websites with YAML configuration and Markdown rendering - ready to use out of the box.

1,458 lines 163 kB
import { g as Wn, a as jn, l as qn } from "./index-DqO065o3.js"; function S(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 o(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 ys = function() { const { crypto: n } = globalThis; if (n != null && n.randomUUID) return ys = 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 pt(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 _t = (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 y extends Error { } class B extends y { constructor(e, t, s, r) { super(`${B.makeMessage(e, t, s)}`), this.status = e, this.headers = r, this.requestID = r == null ? void 0 : r.get("x-request-id"), this.error = t; const a = t; this.code = a == null ? void 0 : a.code, this.param = a == null ? void 0 : a.param, this.type = a == null ? void 0 : a.type; } static makeMessage(e, t, s) { const r = t != null && 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 Ze({ message: s, cause: _t(t) }); const a = t == null ? void 0 : t.error; return e === 400 ? new bs(e, a, s, r) : e === 401 ? new Ss(e, a, s, r) : e === 403 ? new As(e, a, s, r) : e === 404 ? new xs(e, a, s, r) : e === 409 ? new Cs(e, a, s, r) : e === 422 ? new Rs(e, a, s, r) : e === 429 ? new Is(e, a, s, r) : e >= 500 ? new $s(e, a, s, r) : new B(e, a, s, r); } } class H extends B { constructor({ message: e } = {}) { super(void 0, void 0, e || "Request was aborted.", void 0); } } class Ze extends B { constructor({ message: e, cause: t }) { super(void 0, void 0, e || "Connection error.", void 0), t && (this.cause = t); } } class $t extends Ze { constructor({ message: e } = {}) { super({ message: e ?? "Request timed out." }); } } class bs extends B { } class Ss extends B { } class As extends B { } class xs extends B { } class Cs extends B { } class Rs extends B { } class Is extends B { } class $s extends B { } class vs extends y { constructor() { super("Could not parse response content as the length limit was reached"); } } class Es extends y { constructor() { super("Could not parse response content as the request was rejected by the content filter"); } } const Jn = /^[a-z][a-z0-9+.-]*:/i, Xn = (n) => Jn.test(n); function Hn(n) { return typeof n != "object" ? {} : n ?? {}; } function Kn(n) { if (!n) return !0; for (const e in n) return !1; return !0; } function Vn(n, e) { return Object.prototype.hasOwnProperty.call(n, e); } function ot(n) { return n != null && typeof n == "object" && !Array.isArray(n); } const Qn = (n, e) => { if (typeof e != "number" || !Number.isInteger(e)) throw new y(`${n} must be an integer`); if (e < 0) throw new y(`${n} must be a positive integer`); return e; }, Gn = (n) => { try { return JSON.parse(n); } catch { return; } }, $e = (n) => new Promise((e) => setTimeout(e, n)), He = { off: 0, error: 200, warn: 300, info: 400, debug: 500 }, Qt = (n, e, t) => { if (n) { if (Vn(He, n)) return n; U(t).warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(He))}`); } }; function pe() { } function Oe(n, e, t) { return !e || He[n] > He[t] ? pe : e[n].bind(e); } const zn = { error: pe, warn: pe, info: pe, debug: pe }; let Gt = /* @__PURE__ */ new WeakMap(); function U(n) { const e = n.logger, t = n.logLevel ?? "off"; if (!e) return zn; const s = Gt.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 Gt.set(e, [t, r]), r; } const se = (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() === "authorization" || e.toLowerCase() === "cookie" || e.toLowerCase() === "set-cookie" ? "***" : t ]))), "retryOfRequestLogID" in n && (n.retryOfRequestLogID && (n.retryOf = n.retryOfRequestLogID), delete n.retryOfRequestLogID), n), ue = "5.0.1", Yn = () => ( // @ts-ignore typeof window < "u" && // @ts-ignore typeof window.document < "u" && // @ts-ignore typeof navigator < "u" ); function Zn() { 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 er = () => { var t; const n = Zn(); if (n === "deno") return { "X-Stainless-Lang": "js", "X-Stainless-Package-Version": ue, "X-Stainless-OS": Yt(Deno.build.os), "X-Stainless-Arch": zt(Deno.build.arch), "X-Stainless-Runtime": "deno", "X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : ((t = Deno.version) == null ? void 0 : t.deno) ?? "unknown" }; if (typeof EdgeRuntime < "u") return { "X-Stainless-Lang": "js", "X-Stainless-Package-Version": ue, "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": ue, "X-Stainless-OS": Yt(globalThis.process.platform ?? "unknown"), "X-Stainless-Arch": zt(globalThis.process.arch ?? "unknown"), "X-Stainless-Runtime": "node", "X-Stainless-Runtime-Version": globalThis.process.version ?? "unknown" }; const e = tr(); return e ? { "X-Stainless-Lang": "js", "X-Stainless-Package-Version": ue, "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": ue, "X-Stainless-OS": "Unknown", "X-Stainless-Arch": "unknown", "X-Stainless-Runtime": "unknown", "X-Stainless-Runtime-Version": "unknown" }; }; function tr() { 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, a = s[2] || 0, i = s[3] || 0; return { browser: e, version: `${r}.${a}.${i}` }; } } return null; } const zt = (n) => n === "x32" ? "x32" : n === "x86_64" || n === "x64" ? "x64" : n === "arm" ? "arm" : n === "aarch64" || n === "arm64" ? "arm64" : n ? `other:${n}` : "unknown", Yt = (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 Zt; const sr = () => Zt ?? (Zt = er()); function nr() { if (typeof fetch < "u") return fetch; throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`"); } function ks(...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 Os(n) { let e = Symbol.asyncIterator in n ? n[Symbol.asyncIterator]() : n[Symbol.iterator](); return ks({ start() { }, async pull(t) { const { done: s, value: r } = await e.next(); s ? t.close() : t.enqueue(r); }, async cancel() { var t; await ((t = e.return) == null ? void 0 : t.call(e)); } }); } function Ps(n) { if (n[Symbol.asyncIterator]) return n; const e = n.getReader(); return { async next() { try { const t = await e.read(); return t != null && 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 rr(n) { var s, r; if (n === null || typeof n != "object") return; if (n[Symbol.asyncIterator]) { await ((r = (s = n[Symbol.asyncIterator]()).return) == null ? void 0 : r.call(s)); return; } const e = n.getReader(), t = e.cancel(); e.releaseLock(), await t; } const ar = ({ headers: n, body: e }) => ({ bodyHeaders: { "content-type": "application/json" }, body: JSON.stringify(e) }), gt = "RFC3986", wt = { RFC1738: (n) => String(n).replace(/%20/g, "+"), RFC3986: (n) => String(n) }, ir = "RFC1738", or = Array.isArray, V = (() => { const n = []; for (let e = 0; e < 256; ++e) n.push("%" + ((e < 16 ? "0" : "") + e.toString(16)).toUpperCase()); return n; })(), ct = 1024, cr = (n, e, t, s, r) => { if (n.length === 0) return n; let a = n; if (typeof n == "symbol" ? a = Symbol.prototype.toString.call(n) : typeof n != "string" && (a = String(n)), t === "iso-8859-1") return escape(a).replace(/%u[0-9a-f]{4}/gi, function(c) { return "%26%23" + parseInt(c.slice(2), 16) + "%3B"; }); let i = ""; for (let c = 0; c < a.length; c += ct) { const l = a.length >= ct ? a.slice(c, c + ct) : a, h = []; for (let p = 0; p < l.length; ++p) { let u = l.charCodeAt(p); if (u === 45 || // - u === 46 || // . u === 95 || // _ u === 126 || // ~ u >= 48 && u <= 57 || // 0-9 u >= 65 && u <= 90 || // a-z u >= 97 && u <= 122 || // A-Z r === ir && (u === 40 || u === 41)) { h[h.length] = l.charAt(p); continue; } if (u < 128) { h[h.length] = V[u]; continue; } if (u < 2048) { h[h.length] = V[192 | u >> 6] + V[128 | u & 63]; continue; } if (u < 55296 || u >= 57344) { h[h.length] = V[224 | u >> 12] + V[128 | u >> 6 & 63] + V[128 | u & 63]; continue; } p += 1, u = 65536 + ((u & 1023) << 10 | l.charCodeAt(p) & 1023), h[h.length] = V[240 | u >> 18] + V[128 | u >> 12 & 63] + V[128 | u >> 6 & 63] + V[128 | u & 63]; } i += h.join(""); } return i; }; function lr(n) { return !n || typeof n != "object" ? !1 : !!(n.constructor && n.constructor.isBuffer && n.constructor.isBuffer(n)); } function es(n, e) { if (or(n)) { const t = []; for (let s = 0; s < n.length; s += 1) t.push(e(n[s])); return t; } return e(n); } const ur = Object.prototype.hasOwnProperty, Ts = { brackets(n) { return String(n) + "[]"; }, comma: "comma", indices(n, e) { return String(n) + "[" + e + "]"; }, repeat(n) { return String(n); } }, Q = Array.isArray, hr = Array.prototype.push, Ms = function(n, e) { hr.apply(n, Q(e) ? e : [e]); }, dr = Date.prototype.toISOString, N = { addQueryPrefix: !1, allowDots: !1, allowEmptyArrays: !1, arrayFormat: "indices", charset: "utf-8", charsetSentinel: !1, delimiter: "&", encode: !0, encodeDotInKeys: !1, encoder: cr, encodeValuesOnly: !1, format: gt, formatter: wt[gt], /** @deprecated */ indices: !1, serializeDate(n) { return dr.call(n); }, skipNulls: !1, strictNullHandling: !1 }; function fr(n) { return typeof n == "string" || typeof n == "number" || typeof n == "boolean" || typeof n == "symbol" || typeof n == "bigint"; } const lt = {}; function Ns(n, e, t, s, r, a, i, c, l, h, p, u, m, f, A, b, C, D) { let w = n, R = D, g = 0, P = !1; for (; (R = R.get(lt)) !== void 0 && !P; ) { const O = R.get(n); if (g += 1, typeof O < "u") { if (O === g) throw new RangeError("Cyclic object value"); P = !0; } typeof R.get(lt) > "u" && (g = 0); } if (typeof h == "function" ? w = h(e, w) : w instanceof Date ? w = m == null ? void 0 : m(w) : t === "comma" && Q(w) && (w = es(w, function(O) { return O instanceof Date ? m == null ? void 0 : m(O) : O; })), w === null) { if (a) return l && !b ? ( // @ts-expect-error l(e, N.encoder, C, "key", f) ) : e; w = ""; } if (fr(w) || lr(w)) { if (l) { const O = b ? e : l(e, N.encoder, C, "key", f); return [ (A == null ? void 0 : A(O)) + "=" + // @ts-expect-error (A == null ? void 0 : A(l(w, N.encoder, C, "value", f))) ]; } return [(A == null ? void 0 : A(e)) + "=" + (A == null ? void 0 : A(String(w)))]; } const E = []; if (typeof w > "u") return E; let $; if (t === "comma" && Q(w)) b && l && (w = es(w, l)), $ = [{ value: w.length > 0 ? w.join(",") || null : void 0 }]; else if (Q(h)) $ = h; else { const O = Object.keys(w); $ = p ? O.sort(p) : O; } const j = c ? String(e).replace(/\./g, "%2E") : String(e), k = s && Q(w) && w.length === 1 ? j + "[]" : j; if (r && Q(w) && w.length === 0) return k + "[]"; for (let O = 0; O < $.length; ++O) { const v = $[O], oe = ( // @ts-ignore typeof v == "object" && typeof v.value < "u" ? v.value : w[v] ); if (i && oe === null) continue; const it = u && c ? v.replace(/\./g, "%2E") : v, Un = Q(w) ? typeof t == "function" ? t(k, it) : k : k + (u ? "." + it : "[" + it + "]"); D.set(n, g); const Vt = /* @__PURE__ */ new WeakMap(); Vt.set(lt, D), Ms(E, Ns( oe, Un, t, s, r, a, i, c, // @ts-ignore t === "comma" && b && Q(w) ? null : l, h, p, u, m, f, A, b, C, Vt )); } return E; } function mr(n = N) { if (typeof n.allowEmptyArrays < "u" && typeof n.allowEmptyArrays != "boolean") throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided"); if (typeof n.encodeDotInKeys < "u" && typeof n.encodeDotInKeys != "boolean") throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided"); if (n.encoder !== null && typeof n.encoder < "u" && typeof n.encoder != "function") throw new TypeError("Encoder has to be a function."); const e = n.charset || N.charset; if (typeof n.charset < "u" && n.charset !== "utf-8" && n.charset !== "iso-8859-1") throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined"); let t = gt; if (typeof n.format < "u") { if (!ur.call(wt, n.format)) throw new TypeError("Unknown format option provided."); t = n.format; } const s = wt[t]; let r = N.filter; (typeof n.filter == "function" || Q(n.filter)) && (r = n.filter); let a; if (n.arrayFormat && n.arrayFormat in Ts ? a = n.arrayFormat : "indices" in n ? a = n.indices ? "indices" : "repeat" : a = N.arrayFormat, "commaRoundTrip" in n && typeof n.commaRoundTrip != "boolean") throw new TypeError("`commaRoundTrip` must be a boolean, or absent"); const i = typeof n.allowDots > "u" ? n.encodeDotInKeys ? !0 : N.allowDots : !!n.allowDots; return { addQueryPrefix: typeof n.addQueryPrefix == "boolean" ? n.addQueryPrefix : N.addQueryPrefix, // @ts-ignore allowDots: i, allowEmptyArrays: typeof n.allowEmptyArrays == "boolean" ? !!n.allowEmptyArrays : N.allowEmptyArrays, arrayFormat: a, charset: e, charsetSentinel: typeof n.charsetSentinel == "boolean" ? n.charsetSentinel : N.charsetSentinel, commaRoundTrip: !!n.commaRoundTrip, delimiter: typeof n.delimiter > "u" ? N.delimiter : n.delimiter, encode: typeof n.encode == "boolean" ? n.encode : N.encode, encodeDotInKeys: typeof n.encodeDotInKeys == "boolean" ? n.encodeDotInKeys : N.encodeDotInKeys, encoder: typeof n.encoder == "function" ? n.encoder : N.encoder, encodeValuesOnly: typeof n.encodeValuesOnly == "boolean" ? n.encodeValuesOnly : N.encodeValuesOnly, filter: r, format: t, formatter: s, serializeDate: typeof n.serializeDate == "function" ? n.serializeDate : N.serializeDate, skipNulls: typeof n.skipNulls == "boolean" ? n.skipNulls : N.skipNulls, // @ts-ignore sort: typeof n.sort == "function" ? n.sort : null, strictNullHandling: typeof n.strictNullHandling == "boolean" ? n.strictNullHandling : N.strictNullHandling }; } function pr(n, e = {}) { let t = n; const s = mr(e); let r, a; typeof s.filter == "function" ? (a = s.filter, t = a("", t)) : Q(s.filter) && (a = s.filter, r = a); const i = []; if (typeof t != "object" || t === null) return ""; const c = Ts[s.arrayFormat], l = c === "comma" && s.commaRoundTrip; r || (r = Object.keys(t)), s.sort && r.sort(s.sort); const h = /* @__PURE__ */ new WeakMap(); for (let m = 0; m < r.length; ++m) { const f = r[m]; s.skipNulls && t[f] === null || Ms(i, Ns( t[f], f, // @ts-expect-error c, l, s.allowEmptyArrays, s.strictNullHandling, s.skipNulls, s.encodeDotInKeys, s.encode ? s.encoder : null, s.filter, s.sort, s.allowDots, s.serializeDate, s.format, s.formatter, s.encodeValuesOnly, s.charset, h )); } const p = i.join(s.delimiter); let u = s.addQueryPrefix === !0 ? "?" : ""; return s.charsetSentinel && (s.charset === "iso-8859-1" ? u += "utf8=%26%2310003%3B&" : u += "utf8=%E2%9C%93&"), p.length > 0 ? u + p : ""; } function _r(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 ts; function vt(n) { let e; return (ts ?? (e = new globalThis.TextEncoder(), ts = e.encode.bind(e)))(n); } let ss; function ns(n) { let e; return (ss ?? (e = new globalThis.TextDecoder(), ss = e.decode.bind(e)))(n); } var q, J; class et { constructor() { q.set(this, void 0), J.set(this, void 0), S(this, q, new Uint8Array()), S(this, J, null); } decode(e) { if (e == null) return []; const t = e instanceof ArrayBuffer ? new Uint8Array(e) : typeof e == "string" ? vt(e) : e; S(this, q, _r([o(this, q, "f"), t])); const s = []; let r; for (; (r = gr(o(this, q, "f"), o(this, J, "f"))) != null; ) { if (r.carriage && o(this, J, "f") == null) { S(this, J, r.index); continue; } if (o(this, J, "f") != null && (r.index !== o(this, J, "f") + 1 || r.carriage)) { s.push(ns(o(this, q, "f").subarray(0, o(this, J, "f") - 1))), S(this, q, o(this, q, "f").subarray(o(this, J, "f"))), S(this, J, null); continue; } const a = o(this, J, "f") !== null ? r.preceding - 1 : r.preceding, i = ns(o(this, q, "f").subarray(0, a)); s.push(i), S(this, q, o(this, q, "f").subarray(r.index)), S(this, J, null); } return s; } flush() { return o(this, q, "f").length ? this.decode(` `) : []; } } q = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(); et.NEWLINE_CHARS = /* @__PURE__ */ new Set([` `, "\r"]); et.NEWLINE_REGEXP = /\r\n|[\n\r]/g; function gr(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 wr(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; } class z { constructor(e, t) { this.iterator = e, this.controller = t; } static fromSSEResponse(e, t) { let s = !1; async function* r() { if (s) throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream."); s = !0; let a = !1; try { for await (const i of yr(e, t)) if (!a) { if (i.data.startsWith("[DONE]")) { a = !0; continue; } if (i.event === null || i.event.startsWith("response.") || i.event.startsWith("transcript.")) { let c; try { c = JSON.parse(i.data); } catch (l) { throw console.error("Could not parse message into JSON:", i.data), console.error("From chunk:", i.raw), l; } if (c && c.error) throw new B(void 0, c.error, void 0, e.headers); yield c; } else { let c; try { c = JSON.parse(i.data); } catch (l) { throw console.error("Could not parse message into JSON:", i.data), console.error("From chunk:", i.raw), l; } if (i.event == "error") throw new B(void 0, c.error, c.message, void 0); yield { event: i.event, data: c }; } } a = !0; } catch (i) { if (pt(i)) return; throw i; } finally { a || t.abort(); } } return new z(r, t); } /** * Generates a Stream from a newline-separated ReadableStream * where each item is a JSON value. */ static fromReadableStream(e, t) { let s = !1; async function* r() { const i = new et(), c = Ps(e); for await (const l of c) for (const h of i.decode(l)) yield h; for (const l of i.flush()) yield l; } async function* a() { if (s) throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream."); s = !0; let i = !1; try { for await (const c of r()) i || c && (yield JSON.parse(c)); i = !0; } catch (c) { if (pt(c)) return; throw c; } finally { i || t.abort(); } } return new z(a, t); } [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 = (a) => ({ next: () => { if (a.length === 0) { const i = s.next(); e.push(i), t.push(i); } return a.shift(); } }); return [ new z(() => r(e), this.controller), new z(() => r(t), this.controller) ]; } /** * 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 ks({ async start() { t = e[Symbol.asyncIterator](); }, async pull(s) { try { const { value: r, done: a } = await t.next(); if (a) return s.close(); const i = vt(JSON.stringify(r) + ` `); s.enqueue(i); } catch (r) { s.error(r); } }, async cancel() { var s; await ((s = t.return) == null ? void 0 : s.call(t)); } }); } } async function* yr(n, e) { if (!n.body) throw e.abort(), typeof globalThis.navigator < "u" && globalThis.navigator.product === "ReactNative" ? new y("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 y("Attempted to iterate over a response with no body"); const t = new Sr(), s = new et(), r = Ps(n.body); for await (const a of br(r)) for (const i of s.decode(a)) { const c = t.decode(i); c && (yield c); } for (const a of s.flush()) { const i = t.decode(a); i && (yield i); } } async function* br(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" ? vt(t) : t; let r = new Uint8Array(e.length + s.length); r.set(e), r.set(s, e.length), e = r; let a; for (; (a = wr(e)) !== -1; ) yield e.slice(0, a), e = e.slice(a); } e.length > 0 && (yield e); } class Sr { 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 a = { event: this.event, data: this.data.join(` `), raw: this.chunks }; return this.event = null, this.data = [], this.chunks = [], a; } if (this.chunks.push(e), e.startsWith(":")) return null; let [t, s, r] = Ar(e, ":"); return r.startsWith(" ") && (r = r.substring(1)), t === "event" ? this.event = r : t === "data" && this.data.push(r), null; } } function Ar(n, e) { const t = n.indexOf(e); return t !== -1 ? [n.substring(0, t), e, n.substring(t + e.length)] : [n, "", ""]; } async function Fs(n, e) { const { response: t, requestLogID: s, retryOfRequestLogID: r, startTime: a } = e, i = await (async () => { var u; if (e.options.stream) return U(n).debug("response", t.status, t.url, t.headers, t.body), e.options.__streamClass ? e.options.__streamClass.fromSSEResponse(t, e.controller) : z.fromSSEResponse(t, e.controller); if (t.status === 204) return null; if (e.options.__binaryResponse) return t; const c = t.headers.get("content-type"), l = (u = c == null ? void 0 : c.split(";")[0]) == null ? void 0 : u.trim(); if ((l == null ? void 0 : l.includes("application/json")) || (l == null ? void 0 : l.endsWith("+json"))) { const m = await t.json(); return Ls(m, t); } return await t.text(); })(); return U(n).debug(`[${s}] response parsed`, se({ retryOfRequestLogID: r, url: t.url, status: t.status, body: i, durationMs: Date.now() - a })), i; } function Ls(n, e) { return !n || typeof n != "object" || Array.isArray(n) ? n : Object.defineProperty(n, "_request_id", { value: e.headers.get("x-request-id"), enumerable: !1 }); } var _e; class tt extends Promise { constructor(e, t, s = Fs) { super((r) => { r(null); }), this.responsePromise = t, this.parseResponse = s, _e.set(this, void 0), S(this, _e, e); } _thenUnwrap(e) { return new tt(o(this, _e, "f"), this.responsePromise, async (t, s) => Ls(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 X-Request-ID header which is useful for debugging requests and reporting * issues to OpenAI. * * 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("x-request-id") }; } parse() { return this.parsedPromise || (this.parsedPromise = this.responsePromise.then((e) => this.parseResponse(o(this, _e, "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); } } _e = /* @__PURE__ */ new WeakMap(); var Pe; class Bs { constructor(e, t, s, r) { Pe.set(this, void 0), S(this, Pe, 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 y("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`."); return await o(this, Pe, "f").requestAPIList(this.constructor, e); } async *iterPages() { let e = this; for (yield e; e.hasNextPage(); ) e = await e.getNextPage(), yield e; } async *[(Pe = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() { for await (const e of this.iterPages()) for (const t of e.getPaginatedItems()) yield t; } } class xr extends tt { constructor(e, t, s) { super(e, t, async (r, a) => new s(r, a.response, await Fs(r, a), a.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 st extends Bs { constructor(e, t, s, r) { super(e, t, s, r), this.data = s.data || [], this.object = s.object; } getPaginatedItems() { return this.data ?? []; } nextPageRequestOptions() { return null; } } class T extends Bs { constructor(e, t, s, r) { super(e, t, s, r), this.data = s.data || [], this.has_more = s.has_more || !1; } getPaginatedItems() { return this.data ?? []; } hasNextPage() { return this.has_more === !1 ? !1 : super.hasNextPage(); } nextPageRequestOptions() { var s; const e = this.getPaginatedItems(), t = (s = e[e.length - 1]) == null ? void 0 : s.id; return t ? { ...this.options, query: { ...Hn(this.options.query), after: t } } : null; } } const Ds = () => { var n; if (typeof File > "u") { const { process: e } = globalThis, t = typeof ((n = e == null ? void 0 : e.versions) == null ? void 0 : n.node) == "string" && parseInt(e.versions.node.split(".")) < 20; throw new Error("`File` is not defined as a global, which is required for file uploads." + (t ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : "")); } }; function xe(n, e, t) { return Ds(), new File(n, e ?? "unknown_file", t); } function Be(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 Us = (n) => n != null && typeof n == "object" && typeof n[Symbol.asyncIterator] == "function", ie = async (n, e) => ({ ...n, body: await Rr(n.body, e) }), rs = /* @__PURE__ */ new WeakMap(); function Cr(n) { const e = typeof n == "function" ? n : n.fetch, t = rs.get(e); if (t) return t; const s = (async () => { try { const r = "Response" in e ? e.Response : (await e("data:,")).constructor, a = new FormData(); return a.toString() !== await new r(a).text(); } catch { return !0; } })(); return rs.set(e, s), s; } const Rr = async (n, e) => { if (!await Cr(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]) => yt(t, s, r))), t; }, Ir = (n) => n instanceof Blob && "name" in n, yt = 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) n.append(e, xe([await t.blob()], Be(t))); else if (Us(t)) n.append(e, xe([await new Response(Os(t)).blob()], Be(t))); else if (Ir(t)) n.append(e, t, Be(t)); else if (Array.isArray(t)) await Promise.all(t.map((s) => yt(n, e + "[]", s))); else if (typeof t == "object") await Promise.all(Object.entries(t).map(([s, r]) => yt(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`); } }, Ws = (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", $r = (n) => n != null && typeof n == "object" && typeof n.name == "string" && typeof n.lastModified == "number" && Ws(n), vr = (n) => n != null && typeof n == "object" && typeof n.url == "string" && typeof n.blob == "function"; async function Er(n, e, t) { if (Ds(), n = await n, $r(n)) return n instanceof File ? n : xe([await n.arrayBuffer()], n.name); if (vr(n)) { const r = await n.blob(); return e || (e = new URL(n.url).pathname.split(/[\\/]/).pop()), xe(await bt(r), e, t); } const s = await bt(n); if (e || (e = Be(n)), !(t != null && t.type)) { const r = s.find((a) => typeof a == "object" && "type" in a && a.type); typeof r == "string" && (t = { ...t, type: r }); } return xe(s, e, t); } async function bt(n) { var t; let e = []; if (typeof n == "string" || ArrayBuffer.isView(n) || // includes Uint8Array, Buffer, etc. n instanceof ArrayBuffer) e.push(n); else if (Ws(n)) e.push(n instanceof Blob ? n : await n.arrayBuffer()); else if (Us(n)) for await (const s of n) e.push(...await bt(s)); else { const s = (t = n == null ? void 0 : n.constructor) == null ? void 0 : t.name; throw new Error(`Unexpected data type: ${typeof n}${s ? `; constructor: ${s}` : ""}${kr(n)}`); } return e; } function kr(n) { return typeof n != "object" || n === null ? "" : `; props: [${Object.getOwnPropertyNames(n).map((t) => `"${t}"`).join(", ")}]`; } class x { constructor(e) { this._client = e; } } function js(n) { return n.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent); } const Or = (n = js) => function(t, ...s) { if (t.length === 1) return t[0]; let r = !1; const a = t.reduce((p, u, m) => (/[?#]/.test(u) && (r = !0), p + u + (m === s.length ? "" : (r ? encodeURIComponent : n)(String(s[m])))), ""), i = a.split(/[?#]/, 1)[0], c = [], l = new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)", "gi"); let h; for (; (h = l.exec(i)) !== null; ) c.push({ start: h.index, length: h[0].length }); if (c.length > 0) { let p = 0; const u = c.reduce((m, f) => { const A = " ".repeat(f.start - p), b = "^".repeat(f.length); return p = f.start + f.length, m + A + b; }, ""); throw new y(`Path parameters result in path with invalid segments: ${a} ${u}`); } return a; }, d = Or(js); let qs = class extends x { /** * Get the messages in a stored chat completion. Only Chat Completions that have * been created with the `store` parameter set to `true` will be returned. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const chatCompletionStoreMessage of client.chat.completions.messages.list( * 'completion_id', * )) { * // ... * } * ``` */ list(e, t = {}, s) { return this._client.getAPIList(d`/chat/completions/${e}/messages`, T, { query: t, ...s }); } }; function Pr(n) { return typeof n.parse == "function"; } const Ke = (n) => (n == null ? void 0 : n.role) === "assistant", Js = (n) => (n == null ? void 0 : n.role) === "tool"; var St, De, Ue, ge, we, We, ye, Z, be, Ve, Qe, he, Xs; class Et { constructor() { St.add(this), this.controller = new AbortController(), De.set(this, void 0), Ue.set(this, () => { }), ge.set(this, () => { }), we.set(this, void 0), We.set(this, () => { }), ye.set(this, () => { }), Z.set(this, {}), be.set(this, !1), Ve.set(this, !1), Qe.set(this, !1), he.set(this, !1), S(this, De, new Promise((e, t) => { S(this, Ue, e, "f"), S(this, ge, t, "f"); })), S(this, we, new Promise((e, t) => { S(this, We, e, "f"), S(this, ye, t, "f"); })), o(this, De, "f").catch(() => { }), o(this, we, "f").catch(() => { }); } _run(e) { setTimeout(() => { e().then(() => { this._emitFinal(), this._emit("end"); }, o(this, St, "m", Xs).bind(this)); }, 0); } _connected() { this.ended || (o(this, Ue, "f").call(this), this._emit("connect")); } get ended() { return o(this, be, "f"); } get errored() { return o(this, Ve, "f"); } get aborted() { return o(this, Qe, "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 ChatCompletionStream, so that calls can be chained */ on(e, t) { return (o(this, Z, "f")[e] || (o(this, Z, "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 ChatCompletionStream, so that calls can be chained */ off(e, t) { const s = o(this, Z, "f")[e]; if (!s) return this; const r = s.findIndex((a) => a.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 ChatCompletionStream, so that calls can be chained */ once(e, t) { return (o(this, Z, "f")[e] || (o(this, Z, "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) => { S(this, he, !0), e !== "error" && this.once("error", s), this.once(e, t); }); } async done() { S(this, he, !0), await o(this, we, "f"); } _emit(e, ...t) { if (o(this, be, "f")) return; e === "end" && (S(this, be, !0), o(this, We, "f").call(this)); const s = o(this, Z, "f")[e]; if (s && (o(this, Z, "f")[e] = s.filter((r) => !r.once), s.forEach(({ listener: r }) => r(...t))), e === "abort") { const r = t[0]; !o(this, he, "f") && !(s != null && s.length) && Promise.reject(r), o(this, ge, "f").call(this, r), o(this, ye, "f").call(this, r), this._emit("end"); return; } if (e === "error") { const r = t[0]; !o(this, he, "f") && !(s != null && s.length) && Promise.reject(r), o(this, ge, "f").call(this, r), o(this, ye, "f").call(this, r), this._emit("end"); } } _emitFinal() { } } De = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), we = /* @__PURE__ */ new WeakMap(), We = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap(), Qe = /* @__PURE__ */ new WeakMap(), he = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakSet(), Xs = function(e) { if (S(this, Ve, !0), e instanceof Error && e.name === "AbortError" && (e = new H()), e instanceof H) return S(this, Qe, !0), this._emit("abort", e); if (e instanceof y) return this._emit("error", e); if (e instanceof Error) { const t = new y(e.message); return t.cause = e, this._emit("error", t); } return this._emit("error", new y(String(e))); }; function kt(n) { return (n == null ? void 0 : n.$brand) === "auto-parseable-response-format"; } function ve(n) { return (n == null ? void 0 : n.$brand) === "auto-parseable-tool"; } function Tr(n, e) { return !e || !Hs(e) ? { ...n, choices: n.choices.map((t) => ({ ...t, message: { ...t.message, parsed: null, ...t.message.tool_calls ? { tool_calls: t.message.tool_calls } : void 0 } })) } : Ot(n, e); } function Ot(n, e) { const t = n.choices.map((s) => { var r; if (s.finish_reason === "length") throw new vs(); if (s.finish_reason === "content_filter") throw new Es(); return { ...s, message: { ...s.message, ...s.message.tool_calls ? { tool_calls: ((r = s.message.tool_calls) == null ? void 0 : r.map((a) => Nr(e, a))) ?? void 0 } : void 0, parsed: s.message.content && !s.message.refusal ? Mr(e, s.message.content) : null } }; }); return { ...n, choices: t }; } function Mr(n, e) { var t, s; return ((t = n.response_format) == null ? void 0 : t.type) !== "json_schema" ? null : ((s = n.response_format) == null ? void 0 : s.type) === "json_schema" ? "$parseRaw" in n.response_format ? n.response_format.$parseRaw(e) : JSON.parse(e) : null; } function Nr(n, e) { var s; const t = (s = n.tools) == null ? void 0 : s.find((r) => { var a; return ((a = r.function) == null ? void 0 : a.name) === e.function.name; }); return { ...e, function: { ...e.function, parsed_arguments: ve(t) ? t.$parseRaw(e.function.arguments) : t != null && t.function.strict ? JSON.parse(e.function.arguments) : null } }; } function Fr(n, e) { var s; if (!n) return !1; const t = (s = n.tools) == null ? void 0 : s.find((r) => { var a; return ((a = r.function) == null ? void 0 : a.name) === e.function.name; }); return ve(t) || (t == null ? void 0 : t.function.strict) || !1; } function Hs(n) { var e; return kt(n.response_format) ? !0 : ((e = n.tools) == null ? void 0 : e.some((t) => ve(t) || t.type === "function" && t.function.strict === !0)) ?? !1; } function Lr(n) { for (const e of n ?? []) { if (e.type !== "function") throw new y(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``); if (e.function.strict !== !0) throw new y(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`); } } var W, At, Ge, xt, Ct, Rt, Ks, Vs; const Br = 10; class Qs extends Et { constructor() { super(...arguments), W.add(this), this._chatCompletions = [], this.messages = []; } _addChatCompletion(e) { var s; this._chatCompletions.push(e), this._emit("chatCompletion", e); const t = (s = e.choices[0]) == null ? void 0 : s.message; return t && this._addMessage(t), e; } _addMessage(e, t = !0) { if ("content" in e || (e.content = null), this.messages.push(e), t) { if (this._emit("message", e), Js(e) && e.content) this._emit("functionToolCallResult", e.content); else if (Ke(e) && e.tool_calls) for (const s of e.tool_calls) s.type === "function" && this._emit("functionToolCall", s.function); } } /** * @returns a promise that resolves with the final ChatCompletion, or rejects * if an error occurred or the stream ended prematurely without producing a ChatCompletion. */ async finalChatCompletion() { await this.done(); const e = this._chatCompletions[this._chatCompletions.length - 1]; if (!e) throw new y("stream ended without producing a ChatCompletion"); return e; } /** * @returns a promise that resolves with the content of the final ChatCompletionMessage, or rejects * if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage. */ async finalContent() { return await this.done(), o(this, W, "m", At).call(this); } /** * @returns a promise that resolves with the the final assistant ChatCompletionMessage response, * or rejects if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage. */ async finalMessage() { return await this.done(), o(this, W, "m", Ge).call(this); } /** * @returns a promise that resolves with the content of the final FunctionCall, or rejects * if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage. */ async finalFunctionToolCall() { return await this.done(), o(this, W, "m", xt).call(this); } async finalFunctionToolCallResult() { return await this.done(), o(this, W, "m", Ct).call(this); } async totalUsage() { return await this.done(), o(this, W, "m", Rt).call(this); } allChatCompletions() { return [...this._chatCompletions]; } _emitFinal() { const e = this._chatCompletions[this._chatCompletions.length - 1]; e && this._emit("finalChatCompletion", e); const t = o(this, W, "m", Ge).call(this); t && this._emit("finalMessage", t); const s = o(this, W, "m", At).call(this); s && this._emit("finalContent", s); const r = o(this, W, "m", xt).call(this); r && this._emit("finalFunctionToolCall", r); const a = o(this, W, "m", Ct).call(this); a != null && this._emit("finalFunctionToolCallResult", a), this._chatCompletions.some((i) => i.usage) && this._emit("totalUsage", o(this, W, "m", Rt).call(this)); } async _createChatCompletion(e, t, s) { const r = s == null ? void 0 : s.signal; r && (r.aborted && this.controller.abort(), r.addEventListener("abort", () => this.controller.abort())), o(this, W, "m", Ks).call(this, t); const a = await e.chat.completions.create({ ...t, stream: !1 }, { ...s, signal: this.controller.signal }); return this._connected(), this._addChatCompletion(Ot(a, t)); } async _runChatCompletion(e, t, s) { for (const r of t.messages) this._addMessage(r, !1); return await this._createChatCompletion(e, t, s); } async _runTools(e, t, s) { var f, A, b; const r = "tool", { tool_choice: a = "auto", stream: i, ...c } = t, l = typeof a != "string" && ((f = a == null ? void 0 : a.function) == null ? void 0 : f.name), { maxChatCompletions: h = Br } = s || {}, p = t.tools.map((C) => { if (ve(C)) { if (!C.$callback) throw new y("Tool given to `.runTools()` that does not have an associated function"); return { type: "function", function: { function: C.$callback, name: C.function.name, description: C.function.description || "", parameters: C.function.parameters, parse: C.$parseRaw, strict: !0 } }; } return C; }), u = {}; for (const C of p) C.type === "function" && (u[C.function.name || C.function.function.name] = C.function); const m = "tools" in t ? p.map((C) => C.type === "function" ? { type: "function", function: { name: C.function.nam