import React, { useMemo } from "react";
import { normalizeTaskListPropsFromJson } from "../../MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils";
import { TaskList } from "../../TaskList";
import { extractBlockTextContent } from "../extractBlockTextContent";
import { parseJsonBody } from "./utils/parseJsonBody";
import { RendererJsonFallback } from "./utils/RendererJsonFallback";
/**
 * ```agentic-ui-task``` 代码块 → TaskList（与 MarkdownEditor parseCode 对齐）
 */ export var AgenticUiTaskBlockRenderer = function AgenticUiTaskBlockRenderer(props) {
    var code = useMemo(function() {
        return extractBlockTextContent(props.children);
    }, [
        props.children
    ]);
    var parsed = useMemo(function() {
        return parseJsonBody(code);
    }, [
        code
    ]);
    var listProps = useMemo(function() {
        return normalizeTaskListPropsFromJson(parsed);
    }, [
        parsed
    ]);
    if (parsed === null) {
        return /*#__PURE__*/ React.createElement(RendererJsonFallback, {
            testId: "agentic-ui-task-fallback",
            code: code
        });
    }
    return /*#__PURE__*/ React.createElement("div", {
        "data-testid": "agentic-ui-task-block",
        style: {
            margin: '0.75em 0'
        }
    }, /*#__PURE__*/ React.createElement(TaskList, listProps));
};
AgenticUiTaskBlockRenderer.displayName = 'AgenticUiTaskBlockRenderer';
