import { Button as e } from "../../../components/ui/button.js";
import { Textarea as t } from "../../../components/ui/textarea.js";
import n from "../../../components/messages/CompletionMessagePaper.js";
import r from "../../../components/dynamic-form/MarkdownContent.js";
import { useDocumentTransition as i } from "./useDocumentTransition.js";
import { useState as a } from "react";
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
import { Loader2 as l } from "lucide-react";
//#region src/features/documents/renderers/TextPromptRenderer.tsx
var u = ({ parentWorkflow: u, workflow: d, document: f, isActive: p }) => {
	let m = f.content, { submit: h, canSubmit: g, isLoading: _ } = i(u, d, f.ui), [v, y] = a(""), b = !!m.answer, x = !p || !g || b;
	return /* @__PURE__ */ s(n, {
		role: "document",
		fullWidth: !0,
		timestamp: new Date(f.createdAt),
		children: /* @__PURE__ */ c("div", {
			className: "flex flex-col gap-4 p-1",
			children: [/* @__PURE__ */ s(r, { content: m.question }), b ? /* @__PURE__ */ c("div", {
				className: "text-muted-foreground text-sm",
				children: ["Answered: ", /* @__PURE__ */ s("span", {
					className: "text-foreground font-medium",
					children: m.answer
				})]
			}) : /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(t, {
				placeholder: "Type your answer...",
				value: v,
				onChange: (e) => y(e.target.value),
				disabled: x,
				rows: 3
			}), /* @__PURE__ */ s("div", {
				className: "flex justify-end",
				children: /* @__PURE__ */ c(e, {
					type: "button",
					variant: "default",
					disabled: x || _ || !v.trim(),
					onClick: () => {
						let e = v.trim();
						e && h({ answer: e });
					},
					className: "w-48",
					children: [_ && /* @__PURE__ */ s(l, { className: "h-4 w-4 animate-spin" }), "Submit"]
				})
			})] })]
		})
	});
};
//#endregion
export { u as default };
