import { c } from "react/compiler-runtime";
import React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var getDataUrl = (e, n) => e instanceof URL ? e.toString() : typeof e == "string" ? `data:${n || "application/octet-stream"};base64,${e}` : "#", TextPartRenderer = (n) => {
	let r = c(2), { part: i } = n, a;
	return r[0] === i.text ? a = r[1] : (a = /* @__PURE__ */ jsx("div", {
		className: "text-sm leading-relaxed whitespace-pre-wrap",
		children: i.text
	}), r[0] = i.text, r[1] = a), a;
}, ImagePartRenderer = (n) => {
	let a = c(11), { part: o } = n, s;
	a[0] !== o.image || a[1] !== o.mediaType ? (s = getDataUrl(o.image, o.mediaType), a[0] = o.image, a[1] = o.mediaType, a[2] = s) : s = a[2];
	let l;
	a[3] === Symbol.for("react.memo_cache_sentinel") ? (l = { maxHeight: "400px" }, a[3] = l) : l = a[3];
	let u;
	a[4] === s ? u = a[5] : (u = /* @__PURE__ */ jsx("img", {
		src: s,
		alt: "Uploaded image",
		className: "h-auto max-w-full rounded-lg border shadow-sm",
		style: l
	}), a[4] = s, a[5] = u);
	let d;
	a[6] === o.mediaType ? d = a[7] : (d = o.mediaType && /* @__PURE__ */ jsxs("div", {
		className: "mt-1 text-xs text-gray-500",
		children: ["Type: ", o.mediaType]
	}), a[6] = o.mediaType, a[7] = d);
	let f;
	return a[8] !== u || a[9] !== d ? (f = /* @__PURE__ */ jsxs("div", { children: [u, d] }), a[8] = u, a[9] = d, a[10] = f) : f = a[10], f;
}, FilePartRenderer = (n) => {
	let i = c(8), { part: a } = n, o;
	i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ jsx("div", {
		className: "text-2xl",
		children: "📎"
	}), i[0] = o) : o = i[0];
	let s = a.filename || "Unnamed file", l;
	i[1] === s ? l = i[2] : (l = /* @__PURE__ */ jsx("div", {
		className: "text-sm font-medium",
		children: s
	}), i[1] = s, i[2] = l);
	let u;
	i[3] === a.mediaType ? u = i[4] : (u = /* @__PURE__ */ jsx("div", {
		className: "text-xs text-gray-500",
		children: a.mediaType
	}), i[3] = a.mediaType, i[4] = u);
	let d;
	return i[5] !== l || i[6] !== u ? (d = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", {
		className: "flex items-center space-x-2",
		children: [o, /* @__PURE__ */ jsxs("div", { children: [l, u] })]
	}) }), i[5] = l, i[6] = u, i[7] = d) : d = i[7], d;
}, ReasoningPartRenderer = (n) => {
	let i = c(2), { part: a } = n, o;
	return i[0] === a.text ? o = i[1] : (o = a.text ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
		className: "mb-2 flex items-center space-x-2",
		children: /* @__PURE__ */ jsx("div", {
			className: "text-sm font-medium text-purple-600",
			children: "Reasoning"
		})
	}), /* @__PURE__ */ jsx("div", {
		className: "text-sm whitespace-pre-wrap text-purple-800",
		children: a.text
	})] }) : "", i[0] = a.text, i[1] = o), o;
}, ToolCallPartRenderer = (n) => {
	let i = c(17), { part: a } = n, o;
	i[0] === a.toolName ? o = i[1] : (o = /* @__PURE__ */ jsx("div", {
		className: "text-sm font-medium",
		children: a.toolName
	}), i[0] = a.toolName, i[1] = o);
	let s;
	i[2] === a.providerExecuted ? s = i[3] : (s = a.providerExecuted && /* @__PURE__ */ jsx("span", {
		className: "rounded bg-green-100 px-2 py-1 text-xs text-green-800",
		children: "Executed"
	}), i[2] = a.providerExecuted, i[3] = s);
	let l;
	i[4] !== o || i[5] !== s ? (l = /* @__PURE__ */ jsxs("div", {
		className: "flex items-center space-x-2",
		children: [o, s]
	}), i[4] = o, i[5] = s, i[6] = l) : l = i[6];
	let u;
	i[7] === a.toolCallId ? u = i[8] : (u = /* @__PURE__ */ jsxs("div", {
		className: "ml-5 font-mono text-xs text-gray-500",
		children: ["ID: ", a.toolCallId]
	}), i[7] = a.toolCallId, i[8] = u);
	let d;
	i[9] !== l || i[10] !== u ? (d = /* @__PURE__ */ jsxs("div", {
		className: "mb-2 flex items-center justify-between",
		children: [l, u]
	}), i[9] = l, i[10] = u, i[11] = d) : d = i[11];
	let f;
	i[12] === a.input ? f = i[13] : (f = a.input ? /* @__PURE__ */ jsxs("div", {
		className: "rounded border bg-white p-2 text-xs",
		children: [/* @__PURE__ */ jsx("div", {
			className: "mb-1 text-gray-600",
			children: "Input:"
		}), /* @__PURE__ */ jsx("pre", {
			className: "overflow-x-auto whitespace-pre-wrap",
			children: JSON.stringify(a.input, null, 2)
		})]
	}) : "", i[12] = a.input, i[13] = f);
	let p;
	return i[14] !== d || i[15] !== f ? (p = /* @__PURE__ */ jsxs("div", { children: [d, f] }), i[14] = d, i[15] = f, i[16] = p) : p = i[16], p;
}, ToolResultPartRenderer = (n) => {
	let i = c(14), { part: a } = n, o;
	i[0] === a.toolName ? o = i[1] : (o = /* @__PURE__ */ jsxs("div", {
		className: "text-sm font-medium",
		children: [a.toolName, " Result"]
	}), i[0] = a.toolName, i[1] = o);
	let s;
	i[2] === a.toolCallId ? s = i[3] : (s = /* @__PURE__ */ jsxs("div", {
		className: "ml-5 font-mono text-xs text-gray-500",
		children: ["ID: ", a.toolCallId]
	}), i[2] = a.toolCallId, i[3] = s);
	let l;
	i[4] !== o || i[5] !== s ? (l = /* @__PURE__ */ jsxs("div", {
		className: "mb-2 flex items-center justify-between",
		children: [o, s]
	}), i[4] = o, i[5] = s, i[6] = l) : l = i[6];
	let u;
	i[7] === a.output ? u = i[8] : (u = JSON.stringify(a.output, null, 2), i[7] = a.output, i[8] = u);
	let d;
	i[9] === u ? d = i[10] : (d = /* @__PURE__ */ jsx("div", {
		className: "rounded border bg-white p-2 text-xs",
		children: /* @__PURE__ */ jsx("pre", {
			className: "overflow-x-auto whitespace-pre-wrap",
			children: u
		})
	}), i[9] = u, i[10] = d);
	let f;
	return i[11] !== l || i[12] !== d ? (f = /* @__PURE__ */ jsxs("div", { children: [l, d] }), i[11] = l, i[12] = d, i[13] = f) : f = i[13], f;
}, AiMessageContent_default = (n) => {
	let i = c(4), { message: o } = n, s = _temp, l;
	i[0] === o ? l = i[1] : (l = () => {
		if (o.role === "system") return /* @__PURE__ */ jsxs("div", {
			className: "rounded-lg border-l-4 border-gray-400 bg-gray-50 p-3 text-sm text-gray-600 italic",
			children: [/* @__PURE__ */ jsx("div", {
				className: "mb-1 font-medium",
				children: "System"
			}), /* @__PURE__ */ jsx("div", {
				className: "whitespace-pre-wrap",
				children: o.content
			})]
		});
		let { content: e } = o;
		return typeof e == "string" ? /* @__PURE__ */ jsx(TextPartRenderer, { part: {
			type: "text",
			text: e
		} }) : Array.isArray(e) ? /* @__PURE__ */ jsx("div", {
			className: "space-y-2",
			children: e.map((e, n) => s(e, n))
		}) : /* @__PURE__ */ jsx("div", {
			className: "text-sm text-red-600",
			children: "Invalid content format"
		});
	}, i[0] = o, i[1] = l);
	let u = l, d;
	return i[2] === u ? d = i[3] : (d = /* @__PURE__ */ jsx("div", {
		className: "message-content",
		children: u()
	}), i[2] = u, i[3] = d), d;
};
function _temp(e, n) {
	switch (e.type) {
		case "text": return /* @__PURE__ */ jsx(TextPartRenderer, { part: e }, n);
		case "image": return /* @__PURE__ */ jsx(ImagePartRenderer, { part: e }, n);
		case "file": return /* @__PURE__ */ jsx(FilePartRenderer, { part: e }, n);
		case "reasoning": return /* @__PURE__ */ jsx(ReasoningPartRenderer, { part: e }, n);
		case "tool-call": return /* @__PURE__ */ jsx(ToolCallPartRenderer, { part: e }, n);
		case "tool-result": return /* @__PURE__ */ jsx(ToolResultPartRenderer, { part: e }, n);
		default: return /* @__PURE__ */ jsxs("div", {
			className: "rounded bg-gray-100 p-2 text-sm",
			children: ["Unknown content type: ", e.type]
		}, n);
	}
}
export { AiMessageContent_default as default };
