import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, inject as s, isRef as c, normalizeClass as l, normalizeStyle as u, onMounted as d, onUnmounted as f, openBlock as p, provide as m, ref as h, renderList as g, resolveDynamicComponent as _, unref as v, useSlots as y, watch as b } from "vue";
import { useVirtualizer as x } from "@tanstack/vue-virtual";
//#region src/core/fetchSSEStream.ts
var S = class extends Error {
	status;
	statusText;
	constructor(e, t) {
		super(`Fetch SSE failed: ${e} ${t}`), this.name = "FetchSSEError", this.status = e, this.statusText = t;
	}
};
function C(e) {
	let t = (e?.choices)?.[0]?.delta;
	return {
		content: typeof t?.content == "string" ? t.content : "",
		reasoningContent: typeof t?.reasoning_content == "string" && t.reasoning_content ? t.reasoning_content : void 0
	};
}
var w = class {
	abortController;
	options;
	constructor(e) {
		this.abortController = new AbortController(), this.options = e, e.signal && (e.signal.aborted ? this.abortController.abort() : e.signal.addEventListener("abort", () => this.abort(), { once: !0 }));
	}
	abort() {
		this.abortController.abort();
	}
	get aborted() {
		return this.abortController.signal.aborted;
	}
	async *[Symbol.asyncIterator]() {
		let { url: e, method: t, headers: n, body: r, contentExtractor: i, fetchOptions: a } = this.options, o = this.abortController.signal, s = i ?? C, c = await fetch(e, {
			method: t ?? "POST",
			headers: n,
			body: r,
			signal: o,
			...a
		});
		if (!c.ok) throw new S(c.status, c.statusText);
		if (!c.body) throw Error("[streams] Response body is not readable");
		let l = c.body.getReader(), u = new TextDecoder(), d = "";
		try {
			for (;;) {
				if (o.aborted) return;
				let { done: e, value: t } = await l.read();
				if (e) break;
				d += u.decode(t, { stream: !0 });
				let n = d.split("\n");
				d = n.pop() || "";
				for (let e of n) {
					let t = e.trim();
					if (!t || !t.startsWith("data: ")) continue;
					let n = t.slice(6);
					if (n === "[DONE]") return;
					try {
						let e = JSON.parse(n), t = s(e), r = typeof t == "string" ? t : t.content, i = typeof t == "string" ? void 0 : t.reasoningContent;
						(r || i) && (yield {
							content: r ?? "",
							reasoningContent: i,
							raw: e
						});
					} catch {}
				}
			}
		} finally {
			l.releaseLock();
		}
	}
};
function T(e) {
	return new w(e);
}
//#endregion
//#region src/core/customBlock.ts
var E = Symbol("streams-custom-block-render");
//#endregion
//#region src/utils/dom.ts
function D(e) {
	return typeof e == "string" ? document.querySelector(e) : typeof e == "function" ? e() : e;
}
function O(e) {
	let t = {
		"&": "&amp;",
		"<": "&lt;",
		">": "&gt;",
		"\"": "&quot;",
		"'": "&#039;"
	};
	return e.replace(/[&<>"']/g, (e) => t[e] ?? e);
}
function k(e) {
	return Array.from(e);
}
//#endregion
//#region src/composables/useSmoothRenderer.ts
function A(e, n = {}) {
	let r = n.speed ?? 2, i = n.enabled ?? !0, a = n.paragraphMode ?? !1, o = h(""), s = h(!1), c = null, l = [], u = 0, d = 0, p = h(""), m = t(() => {
		let e = p.value;
		return e ? o.value.slice(0, o.value.length - e.length) : o.value;
	});
	function g() {
		c !== null && (cancelAnimationFrame(c), c = null);
	}
	function _(e, t) {
		let n = e + t;
		if (n >= l.length) return l.length;
		let r = Math.min(e + t * 5, l.length), i = n;
		for (; i < r;) {
			if (l[i - 1] === "\n" && l[i] === "\n") return i + 1;
			i++;
		}
		return n;
	}
	function v() {
		if (u < l.length) {
			let e;
			e = a ? _(u, r) : Math.min(u + r, l.length), o.value = l.slice(0, e).join(""), u = e, s.value = !0, c = requestAnimationFrame(v);
		} else p.value = "", s.value = !1, c = null, n.onComplete?.();
	}
	b(e, (e) => {
		if (!i) {
			o.value = e, p.value = "", u = k(e).length, d = e.length;
			return;
		}
		if (e.length > d) {
			let t = k(e.slice(d));
			l = [...l, ...t], d = e.length, s.value || (c = requestAnimationFrame(v));
		} else e.length < d && (l = k(e), u = l.length, o.value = e, p.value = "", d = e.length);
	}, { immediate: !0 });
	function y() {
		g(), o.value = e.value, p.value = "", l = k(e.value), u = l.length, d = e.value.length, s.value = !1;
	}
	function x() {
		g(), o.value = "", p.value = "", l = [], u = 0, d = 0, s.value = !1;
	}
	return f(() => {
		g();
	}), {
		displayed: o,
		confirmed: m,
		tail: p,
		isAnimating: s,
		skip: y,
		reset: x
	};
}
//#endregion
//#region src/renderers/highlighter.ts
var j = null, M = null, N = [
	"javascript",
	"typescript",
	"python",
	"java",
	"go",
	"rust",
	"css",
	"html",
	"json",
	"bash",
	"markdown",
	"vue",
	"yaml",
	"sql",
	"shell"
], P = ["github-dark", "github-light"];
async function F() {
	return j || M || (M = (async () => {
		try {
			let { createHighlighter: e } = await import("./dist-Bw2HRX94.js");
			return j = await e({
				themes: P,
				langs: N
			}), j;
		} catch {
			return console.warn("[streams] shiki not installed, falling back to plain code"), null;
		}
	})(), M);
}
function I() {
	return j;
}
async function L() {
	let e = await F();
	if (!e) return null;
	try {
		let { fromHighlighter: t } = await import("./dist-CXtbGBOE.js");
		return t(e, {
			themes: {
				dark: "github-dark",
				light: "github-light"
			},
			fallbackLanguage: "plaintext"
		});
	} catch {
		return console.warn("[streams] @shikijs/markdown-it not installed, code blocks in markdown will not be highlighted"), null;
	}
}
//#endregion
//#region src/renderers/markdownRenderer.ts
var R = null, z = null, B = null;
function V(e) {
	B = e;
}
async function H() {
	return R || z || (z = (async () => {
		try {
			let { default: e } = await import("./markdown-it-Cmnmr_nU.js"), t = new e({
				html: !0,
				linkify: !0,
				typographer: !0
			}), n = await L();
			return n && t.use(n), R = t, B?.(), R;
		} catch {
			return console.warn("[streams] markdown-it not installed, falling back to plain text"), null;
		}
	})(), z);
}
function ee() {
	return R;
}
function te(e) {
	return (e.match(/```/g) || []).length % 2 != 0 || (e.match(/(?<!`)`(?!`)/g) || []).length % 2 != 0;
}
function U(e) {
	return btoa(unescape(encodeURIComponent(e)));
}
function W(e) {
	try {
		return decodeURIComponent(escape(atob(e)));
	} catch {
		return atob(e);
	}
}
var G = "<!--STREAMS-CUSTOM-BLOCK-";
function ne(e, t) {
	let n = /* @__PURE__ */ new Map();
	if (!t.length) return {
		processed: e,
		extracted: n
	};
	let r = RegExp(`^\\\`\\\`\\\`(${t.join("|")})\\s*\\n([\\s\\S]*?)\\n\\\`\\\`\\\`\\s*$`, "gm"), i = 0;
	return {
		processed: e.replace(r, (e, t, r) => {
			let a = `${i}`, o = U(r);
			return n.set(a, {
				type: t,
				content: o
			}), i++, `${G}${a}-->`;
		}),
		extracted: n
	};
}
function re(e, t) {
	if (!t.size) return e;
	for (let [n, { type: r, content: i }] of t) {
		let t = `${G}${n}-->`;
		if (e.indexOf(t) === -1) continue;
		let a = `<div data-streams-block="${r}" data-content="${i}"></div>`;
		e = e.replace(t, a);
	}
	return e;
}
function ie(e, t) {
	return e.replace(/<pre([^>]*)><code\s+class="language-(\w+)">([\s\S]*?)<\/code><\/pre>/g, (e, n, r, i) => {
		if (t?.includes(r)) {
			let e = document.createElement("div");
			return e.innerHTML = i, `<div data-streams-block="${r}" data-content="${U(e.textContent ?? "")}"></div>`;
		}
		return `<div class="streams-code-wrapper" data-lang="${r}"><div class="streams-code-header"><span class="streams-code-lang">${ae[r] ?? r.charAt(0).toUpperCase() + r.slice(1)}</span></div><pre${n}><code class="language-${r}">${i}</code></pre></div>`;
	});
}
var ae = {
	js: "JavaScript",
	ts: "TypeScript",
	py: "Python",
	rb: "Ruby",
	go: "Go",
	rs: "Rust",
	java: "Java",
	cpp: "C++",
	c: "C",
	cs: "C#",
	php: "PHP",
	swift: "Swift",
	kt: "Kotlin",
	sh: "Shell",
	bash: "Bash",
	zsh: "Zsh",
	sql: "SQL",
	html: "HTML",
	css: "CSS",
	scss: "SCSS",
	less: "Less",
	json: "JSON",
	yaml: "YAML",
	toml: "TOML",
	xml: "XML",
	md: "Markdown",
	dockerfile: "Dockerfile",
	makefile: "Makefile",
	vue: "Vue",
	jsx: "JSX",
	tsx: "TSX",
	dart: "Dart"
}, K = class {
	fallbackRenderer = null;
	_onReady = null;
	customBlocks;
	constructor(e) {
		this.customBlocks = e ?? [];
	}
	setFallback(e) {
		this.fallbackRenderer = e;
	}
	onReady(e) {
		this._onReady = e, V(e);
	}
	render(e, t) {
		let n = ee();
		return n ? this.renderWithMd(n, e, t) : this.fallbackRenderer?.render(e, t) ?? e;
	}
	async renderAsync(e, t) {
		let n = await H();
		return n ? this.renderWithMd(n, e, t) : this.fallbackRenderer?.render(e, t) ?? e;
	}
	renderWithMd(e, t, n) {
		let r = t;
		n && te(r) && (r = this.tryCloseBlocks(r));
		let { processed: i, extracted: a } = ne(r, this.customBlocks), o = re(e.render(i), a);
		return o = ie(o, this.customBlocks), n && (o = o.replace(/<hr\s*\/?>\s*$/i, "")), o;
	}
	tryCloseBlocks(e) {
		let t = e;
		return (t.match(/```/g) || []).length % 2 != 0 && (t += "\n```"), (t.match(/(?<!`)`(?!`)/g) || []).length % 2 != 0 && (t += "`"), t;
	}
	async preload() {
		await H();
	}
}, oe = {
	estimateHeight: 40,
	overscan: 5,
	anchorToBottom: !0,
	scrollThreshold: 80,
	scrollBehavior: "smooth"
}, q = "", J = [];
function se(e) {
	if (!e?.trim()) return q ? (q = "", J = [], []) : [];
	if (e === q) return J;
	let t = document.createElement("div");
	t.innerHTML = e;
	let n = [], r = 0;
	for (let e of Array.from(t.childNodes)) if (e.nodeType === Node.ELEMENT_NODE) {
		let t = e, i = t.getAttribute("data-streams-block"), a = t.getAttribute("data-content");
		if (i) {
			let e = a ? W(a) : "";
			n.push({
				html: "",
				type: "custom-block",
				block: {
					type: i,
					content: e
				}
			});
		} else n.push({
			html: t.outerHTML,
			type: "html"
		});
		r++;
	} else if (e.nodeType === Node.TEXT_NODE) {
		let t = e.textContent;
		t?.trim() && (n.push({
			html: t,
			type: "html"
		}), r++);
	}
	let i = [], a = Math.min(J.length, n.length);
	for (let e = 0; e < n.length; e++) {
		let t = n[e], r = e < a ? J[e] : null;
		if (r && r.type === t.type) {
			if (t.type === "custom-block" && r.type === "custom-block") {
				if (r.block?.type === t.block?.type && r.block?.content === t.block?.content) {
					i.push(r);
					continue;
				}
			} else if (t.type === "html" && r.type === "html" && r.html === t.html) {
				i.push(r);
				continue;
			}
		}
		i.push({
			type: t.type,
			html: t.html,
			block: t.block,
			index: e,
			key: `seg-${e}`
		});
	}
	return q = e, J = i, i;
}
function Y(e) {
	if (!e?.trim()) return [];
	let t = document.createElement("div");
	t.innerHTML = e;
	let n = [], r = 0;
	for (let e of Array.from(t.childNodes)) if (e.nodeType === Node.ELEMENT_NODE) {
		let t = e, i = t.getAttribute("data-streams-block"), a = t.getAttribute("data-content");
		if (i) {
			let e = a ? W(a) : "";
			n.push({
				type: "custom-block",
				html: "",
				block: {
					type: i,
					content: e
				},
				index: r,
				key: `seg-${r}`
			});
		} else n.push({
			type: "html",
			html: t.outerHTML,
			index: r,
			key: `seg-${r}`
		});
		r++;
	} else if (e.nodeType === Node.TEXT_NODE) {
		let t = e.textContent;
		t?.trim() && (n.push({
			type: "html",
			html: t,
			index: r,
			key: `seg-${r}`
		}), r++);
	}
	return n;
}
function X(e, n, r = {}) {
	let i = {
		...oe,
		...r
	}, a = h(e.value), o = null, s = e.value;
	b(e, (e) => {
		s = e, o ||= requestAnimationFrame(() => {
			a.value = s, o = null;
		});
	}, { immediate: !0 });
	let c = t(() => se(a.value)), l = x(t(() => ({
		count: c.value.length,
		getScrollElement: () => n.value,
		estimateSize: (e) => {
			let t = c.value[e];
			return t ? t.html.includes("<pre") ? Math.max((t.html.match(/\n/g) || []).length, 2) * 21 + 32 : /<h[1-3][> ]/.test(t.html) ? i.estimateHeight * 1.5 : t.html.includes("<table") ? i.estimateHeight * 4 : i.estimateHeight : i.estimateHeight;
		},
		overscan: i.overscan,
		anchorTo: i.anchorToBottom ? "end" : "start"
	}))), u = t(() => l.value.getVirtualItems()), d = t(() => l.value.getTotalSize()), p = h(!1), m = null;
	function g() {
		let e = n.value;
		e && (m = () => {
			e && (p.value = e.scrollHeight - e.scrollTop - e.clientHeight > i.scrollThreshold);
		}, e.addEventListener("scroll", m, { passive: !0 }));
	}
	function _() {
		n.value && m && n.value.removeEventListener("scroll", m), m = null;
	}
	b(a, () => {
		!i.anchorToBottom || p.value || requestAnimationFrame(() => {
			let e = c.value.length;
			e > 0 && l.value.scrollToIndex(e - 1, {
				align: "end",
				behavior: i.scrollBehavior
			});
		});
	}), b(n, (e) => {
		_(), e && g();
	}, { immediate: !0 }), f(() => {
		_(), o &&= (cancelAnimationFrame(o), null), q = "", J = [];
	});
	function v(e) {
		e && l.value.measureElement(e);
	}
	function y(e) {
		let t = n.value;
		t && (t.scrollTo({
			top: t.scrollHeight,
			behavior: e ?? i.scrollBehavior
		}), p.value = !1);
	}
	return {
		segments: c,
		virtualizer: l,
		virtualItems: u,
		totalSize: d,
		measureElement: v,
		scrollToBottom: y,
		isUserScrolledAway: p
	};
}
//#endregion
//#region src/renderers/textRenderer.ts
var Z = class {
	render(e, t) {
		return O(e).replace(/\n/g, "<br>");
	}
};
//#endregion
//#region src/utils/scroll.ts
function Q(e) {
	let t = {
		enabled: !0,
		behavior: "smooth",
		container: void 0,
		threshold: 100
	};
	return e ? e === !0 ? t : {
		...t,
		...e
	} : {
		...t,
		enabled: !1
	};
}
function $(e, t = 100) {
	let { scrollTop: n, scrollHeight: r, clientHeight: i } = e;
	return r - n - i <= t;
}
function ce(e, t = "smooth") {
	e.scrollTo({
		top: e.scrollHeight,
		behavior: t
	});
}
var le = class {
	container = null;
	options;
	userScrolled = !1;
	handleUserScroll = null;
	constructor(e) {
		this.options = Q(e);
	}
	bind(e) {
		this.unbind(), this.container = D(e), this.container && (this.userScrolled = !1, this.handleUserScroll = () => {
			this.container && (this.userScrolled = !$(this.container, this.options.threshold));
		}, this.container.addEventListener("scroll", this.handleUserScroll, { passive: !0 }));
	}
	unbind() {
		this.container && this.handleUserScroll && this.container.removeEventListener("scroll", this.handleUserScroll), this.container = null, this.handleUserScroll = null, this.userScrolled = !1;
	}
	tryScroll() {
		!this.options.enabled || !this.container || this.userScrolled || ce(this.container, this.options.behavior);
	}
	updateOptions(e) {
		this.options = Q(e);
	}
	destroy() {
		this.unbind();
	}
}, ue = /* @__PURE__ */ o({
	__name: "StreamSegmentRenderer",
	props: {
		html: {},
		index: {}
	},
	setup(e) {
		let t = e, n = h(null), r = "";
		function a(e) {
			return e.includes("<pre") && e.includes("language-");
		}
		function o(e, t) {
			return !(e.match(/^<pre[^>]*>/)?.[0] !== t.match(/^<pre[^>]*>/)?.[0] || e.match(/<code[^>]*>/)?.[0] !== t.match(/<code[^>]*>/)?.[0]);
		}
		function s(e, t) {
			let n = e.querySelector("code");
			if (!n) {
				e.innerHTML = t;
				return;
			}
			let r = t.match(/<code[^>]*>([\s\S]*)<\/code>/);
			if (!r) {
				e.innerHTML = t;
				return;
			}
			let i = r?.[1];
			if (!i) {
				e.innerHTML = t;
				return;
			}
			let a = n.innerHTML;
			if (i.startsWith(a) && a.length > 0) {
				let e = i.slice(a.length);
				if (e) {
					let t = document.createElement("div");
					for (t.innerHTML = e; t.firstChild;) n.appendChild(t.firstChild);
				}
			} else n.innerHTML = i;
		}
		function c(e, t, n) {
			if (!t || t.length === 0) return !1;
			if (n.startsWith(t)) {
				let r = n.slice(t.length);
				if (r) {
					let t = document.createElement("div");
					for (t.innerHTML = r; t.firstChild;) e.appendChild(t.firstChild);
				}
				return !0;
			}
			let r = t.match(/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/), i = n.match(/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/);
			if (r && i && r[1] === i[1] && r[2] === i[2]) {
				let t = r[3] ?? "", n = i[3] ?? "";
				if (n.startsWith(t) && t.length > 0) {
					let r = n.slice(t.length);
					if (r) {
						let t = e.firstElementChild;
						if (t) {
							let e = document.createElement("div");
							for (e.innerHTML = r; e.firstChild;) t.appendChild(e.firstChild);
						} else {
							let t = document.createElement("div");
							for (t.innerHTML = r; t.firstChild;) e.appendChild(t.firstChild);
						}
					}
					return !0;
				}
			}
			return !1;
		}
		return d(() => {
			n.value && t.html && (n.value.innerHTML = t.html, r = t.html);
		}), b(() => t.html, (e) => {
			let t = n.value;
			if (!t || e === r) return;
			let i = a(r), l = a(e);
			l && i && o(r, e) ? s(t, e) : !l && !i && c(t, r, e) || (t.innerHTML = e), r = e;
		}), (e, t) => (p(), i("div", {
			ref_key: "segmentRef",
			ref: n,
			class: "stream-segment"
		}, null, 512));
	}
}), de = ["data-index"], fe = /* @__PURE__ */ o({
	__name: "VirtualStreamContent",
	props: {
		html: {},
		anchorToBottom: {
			type: Boolean,
			default: !0
		},
		estimateHeight: { default: 40 },
		overscan: { default: 5 },
		scrollThreshold: { default: 80 },
		contentClass: { default: "" }
	},
	setup(r, { expose: o }) {
		let c = r, d = s(E), m = t(() => d?.value ?? {}), y = h(null), x = h(0), S = null, { segments: C, virtualItems: w, totalSize: T, measureElement: D, scrollToBottom: O, isUserScrolledAway: k } = X(t(() => c.html), y, t(() => ({
			estimateHeight: c.estimateHeight,
			overscan: c.overscan,
			anchorToBottom: c.anchorToBottom,
			scrollThreshold: c.scrollThreshold
		})).value);
		return b(y, (e) => {
			S?.disconnect(), e?.parentElement && (S = new ResizeObserver((e) => {
				for (let t of e) x.value = t.contentBoxSize[0]?.blockSize ?? t.contentRect.height;
			}), S.observe(e.parentElement));
		}, { immediate: !0 }), f(() => {
			S?.disconnect();
		}), o({
			scrollToBottom: O,
			containerRef: y,
			isUserScrolledAway: k
		}), (t, o) => (p(), i("div", {
			ref_key: "containerRef",
			ref: y,
			class: "streams-virtual-scroll",
			style: u(x.value ? { height: `${x.value}px` } : void 0)
		}, [a("div", { style: u({
			height: `${v(T)}px`,
			width: "100%",
			position: "relative"
		}) }, [(p(!0), i(e, null, g(v(w), (e) => (p(), i("div", {
			key: String(e.key),
			ref_for: !0,
			ref: (e) => v(D)(e),
			"data-index": e.index,
			class: l(r.contentClass),
			style: u({
				position: "absolute",
				top: 0,
				left: 0,
				width: "100%",
				transform: `translateY(${e.start}px)`
			})
		}, [v(C)[e.index]?.type === "custom-block" && v(C)[e.index]?.block ? (p(), n(_(m.value[v(C)[e.index].block.type]), {
			key: 0,
			block: v(C)[e.index].block
		}, null, 8, ["block"])) : (p(), n(ue, {
			key: 1,
			html: v(C)[e.index]?.html ?? "",
			index: e.index
		}, null, 8, ["html", "index"]))], 14, de))), 128))], 4)], 4));
	}
}), pe = ["innerHTML"], me = ["innerHTML"], he = /* @__PURE__ */ o({
	__name: "Stream",
	props: {
		source: {},
		streaming: {
			type: Boolean,
			default: !1
		},
		smoothSpeed: { default: 2 },
		autoScroll: {
			type: Boolean,
			default: !0
		},
		virtual: {
			type: [Boolean, Object],
			default: !1
		},
		customBlocks: { default: () => [] }
	},
	emits: ["complete", "error"],
	setup(a, { expose: s, emit: u }) {
		let f = a, v = u, x = h(null), S = h(null), C = t(() => c(f.source)), w = t(() => C.value ? f.source.value : f.source ?? ""), T = t(() => C.value ? f.streaming : !1), D = A(t(() => C.value ? w.value : ""), {
			speed: f.smoothSpeed,
			enabled: C.value && f.smoothSpeed > 0
		}), O = t(() => C.value && f.smoothSpeed > 0 ? D.displayed.value : w.value), k = h(0), j = new Z(), M = new K(f.customBlocks);
		M.setFallback(j), M.onReady(() => {
			k.value++;
		});
		let N = t(() => (k.value, M.render(O.value, T.value))), P = y(), F = /* @__PURE__ */ new Map();
		function I(e) {
			return F.has(e) || F.set(e, o({
				name: `StreamsCustomBlock_${e}`,
				props: { block: {
					type: Object,
					required: !0
				} },
				setup(t) {
					return () => {
						let n = P[e];
						return n ? n(t.block) : null;
					};
				}
			})), F.get(e);
		}
		let L = t(() => {
			let e = {};
			for (let t of f.customBlocks) e[t] = I(t);
			return e;
		});
		m(E, L);
		let R = t(() => f.customBlocks.length ? Y(N.value) : null);
		d(() => {
			M.preload();
		});
		let z = t(() => !!f.virtual), B = t(() => typeof f.virtual == "object" ? {
			anchorToBottom: f.autoScroll,
			...f.virtual
		} : { anchorToBottom: f.autoScroll }), V = new le(z.value ? !1 : f.autoScroll);
		return b(x, (e) => {
			e && V.bind(e);
		}, { immediate: !0 }), b(N, () => {
			z.value || V.tryScroll();
		}), b(T, (e, t) => {
			t && !e && v("complete");
		}), s({
			skipSmooth: D.skip,
			scrollToBottom: () => {
				z.value ? S.value?.scrollToBottom() : V.tryScroll();
			},
			reset: D.reset,
			content: O,
			isStreaming: T
		}), (t, a) => (p(), i("div", {
			ref_key: "containerRef",
			ref: x,
			class: l(["streams-markdown", T.value ? "streams-status-streaming" : w.value ? "streams-status-completed" : "streams-status-idle"])
		}, [z.value ? (p(), n(fe, {
			key: 0,
			ref_key: "virtualContentRef",
			ref: S,
			html: N.value,
			"anchor-to-bottom": B.value.anchorToBottom,
			"estimate-height": B.value.estimateHeight,
			overscan: B.value.overscan,
			"scroll-threshold": B.value.scrollThreshold,
			"content-class": "streams-md-content"
		}, null, 8, [
			"html",
			"anchor-to-bottom",
			"estimate-height",
			"overscan",
			"scroll-threshold"
		])) : (p(), i(e, { key: 1 }, [R.value ? (p(!0), i(e, { key: 0 }, g(R.value, (t) => (p(), i(e, { key: t.key }, [t.type === "html" ? (p(), i("div", {
			key: 0,
			class: "streams-md-content",
			innerHTML: t.html
		}, null, 8, pe)) : t.type === "custom-block" && t.block && L.value[t.block.type] ? (p(), n(_(L.value[t.block.type]), {
			key: 1,
			block: t.block
		}, null, 8, ["block"])) : r("", !0)], 64))), 128)) : (p(), i("div", {
			key: 1,
			class: "streams-md-content",
			innerHTML: N.value
		}, null, 8, me))], 64))], 2));
	}
});
//#endregion
export { le as AutoScrollManager, E as CUSTOM_BLOCK_RENDER_KEY, N as DEFAULT_LANGUAGES, P as DEFAULT_THEMES, S as FetchSSEError, w as FetchSSEStream, K as MarkdownRenderer, he as Stream, ue as StreamSegmentRenderer, Z as TextRenderer, fe as VirtualStreamContent, T as createFetchSSEStream, L as createMdHighlightPlugin, W as decodeBase64, D as ensureElement, O as escapeHtml, F as getHighlighter, I as getHighlighterSync, $ as isNearBottom, Q as resolveAutoScrollOptions, ce as scrollToBottom, k as splitChars, Y as splitHtmlToSegments, A as useSmoothRenderer, X as useVirtualStream };
