import { Message as e, MessageAction as t, MessageActions as n, MessageContent as r, MessageResponse as i } from "../../../components/ai-elements/message.js";
import { Reasoning as a, ReasoningContent as o, ReasoningTrigger as s } from "../../../components/ai-elements/reasoning.js";
import { Source as c, Sources as l, SourcesContent as u, SourcesTrigger as d } from "../../../components/ai-elements/sources.js";
import { Tool as f, ToolContent as p, ToolHeader as m, ToolInput as h, ToolOutput as g } from "../../../components/loopstack-elements/tool.js";
import { getToolOrDynamicToolName as _, isReasoningUIPart as v, isTextUIPart as y, isToolOrDynamicToolUIPart as b } from "../../../types/ai.types.js";
import { Fragment as x } from "react";
import { jsx as S, jsxs as C } from "react/jsx-runtime";
import { CopyIcon as w } from "lucide-react";
//#region src/features/documents/renderers/AiMessage.tsx
var T = ({ document: T }) => {
	let E = T.content, D = E.parts?.filter((e) => e.type === "source-url") ?? [];
	return /* @__PURE__ */ C(x, { children: [E.role === "assistant" && D.length > 0 && /* @__PURE__ */ C(l, { children: [/* @__PURE__ */ S(d, { count: D.length }), D.map((e, t) => /* @__PURE__ */ S(u, { children: /* @__PURE__ */ S(c, {
		href: e.url,
		title: e.url
	}) }, `${E.id}-source-${t}`))] }), E.parts?.map((c, l) => {
		if (y(c)) return /* @__PURE__ */ C(e, {
			from: E.role,
			children: [/* @__PURE__ */ S(r, { children: /* @__PURE__ */ S(i, { children: c.text }) }), E.role === "assistant" && /* @__PURE__ */ S(n, { children: /* @__PURE__ */ S(t, {
				onClick: () => void navigator.clipboard.writeText(c.text),
				label: "Copy",
				children: /* @__PURE__ */ S(w, { className: "size-3" })
			}) })]
		}, `${E.id}-${l}`);
		if (v(c)) return /* @__PURE__ */ C(a, {
			className: "w-full",
			isStreaming: !1,
			children: [/* @__PURE__ */ S(s, {}), /* @__PURE__ */ S(o, { children: c.text })]
		}, `${E.id}-${l}`);
		if (b(c)) {
			let t = _(c);
			return /* @__PURE__ */ S(e, {
				from: E.role,
				children: /* @__PURE__ */ C(f, { children: [/* @__PURE__ */ S(m, {
					state: c.state,
					title: t,
					type: c.type
				}), /* @__PURE__ */ C(p, { children: [/* @__PURE__ */ S(h, { input: c.input }), /* @__PURE__ */ S(g, {
					output: c.output,
					errorText: c.errorText ?? ""
				})] })] })
			}, `${E.id}-${l}`);
		}
		return null;
	})] });
};
//#endregion
export { T as default };
